stevedonovan / chrono-english

Converting informal English dates (like `date` command) to chrono DateTime in Rust
MIT License
57 stars 14 forks source link

Update types.rs #17

Closed tiamunley closed 2 years ago

tiamunley commented 3 years ago

Fixed type errors in chrono-english by switching from time::Duration to chrono::Duration type

Error message before this patch:

stderr: error[E0308]: mismatched types
  --> fbcode/buck-out/dev/cells/fbsource/bin/aab7ed39/third-party/rust/chrono-english#platform009-clang,rlib-pic/third-party/rust/vendor/chrono-english-0.1.6/src/types.rs:54:29
   |
54 |     base.checked_add_signed(Duration::days(days))
   |                             ^^^^^^^^^^^^^^^^^^^^ expected struct `chrono::Duration`, found struct `time::Duration`

error[E0308]: mismatched types
   --> fbcode/buck-out/dev/cells/fbsource/bin/aab7ed39/third-party/rust/chrono-english#platform009-clang,rlib-pic/third-party/rust/vendor/chrono-english-0.1.6/src/types.rs:193:21
    |
193 |                     Duration::seconds((secs as i64)*(self.skip as i64))
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `chrono::Duration`, found struct `time::Duration`

error[E0308]: mismatched types
   --> fbcode/buck-out/dev/cells/fbsource/bin/aab7ed39/third-party/rust/chrono-english#platform009-clang,rlib-pic/third-party/rust/vendor/chrono-english-0.1.6/src/types.rs:199:21
    |
199 |                     Duration::seconds((secs as i64)*(self.skip as i64))
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `chrono::Duration`, found struct `time::Duration`

error: aborting due to 3 previous errors

Example script after this patch:

Output: Fri Apr  1 00:00:00 2022 +0000
Output: 2022-04-01T00:00:00+00:00
Output: 1648771200
Timestamp: 1648771200
tamird commented 2 years ago

I think all these changes have been separately committed.

tiamunley commented 2 years ago

Yes, thanks