109 Commits

Author SHA1 Message Date
jtmoon79
5bc022ca81 RFC 2822 single-letter obsolete tests
Add follow-up tests to PR #1013

Link to RFC 2822 section.
2023-04-13 09:25:11 +02:00
Paul Dicker
5ecf30b36e Fix military timezones in RFC 2822 parsing 2023-04-12 14:35:34 +02:00
Dirkjan Ochtman
22b4d32498 Avoid use of deprecated API 2022-11-09 13:37:17 +01:00
Dirkjan Ochtman
7cd5e03ee4 Fix up internal calls to newly deprecated methods 2022-10-09 14:15:02 +02:00
Jarosław Konik
5f5410163b
GNU coreutils date-like time zone formatting (#759)
Co-authored-by: Eric Sheppard <key2@eric.sheppard.cloud>
2022-08-17 18:41:48 +02:00
Finomnis
5eacc0a698 Fixed incorrect whitespace parsing; added more tests 2022-07-26 09:59:19 +02:00
Eric Sheppard
b2430c2b77 change to raw strings 2022-07-26 09:59:19 +02:00
Dirkjan Ochtman
ad1fe57f9b Simplify RFC 2822 comment parser 2022-07-26 09:59:19 +02:00
Finomnis
acd4ecf09f
Add compatibility with rfc2822 comments (#733)
* Add compatibility with rfc2822 comments

* Refactor rfc2822 comment parser
2022-07-24 20:17:38 +10:00
Dirkjan Ochtman
66898813de Reduce lint allowing 2022-03-21 22:32:31 -07:00
Dirkjan Ochtman
2368e37f8e Adopt modern clippy suggestions 2022-03-21 22:20:27 -07:00
Dirkjan Ochtman
e4c8a529f5 Update to 2018 edition (and MSRV 1.32) 2022-03-19 20:38:12 -07:00
Dirkjan Ochtman
216c18f62a Clean up clippy warnings 2022-02-28 18:05:35 +01:00
Rob Young
b0f32832a7
Add documentation for DateTime FromStr impl (#516)
Resolves #505
2020-12-22 11:04:17 -05:00
Aleksandr Bashurov
f4c42b4f14
Skip IANA TZ names when parsing %Z specifier (#473) 2020-08-21 11:56:10 -04:00
Brandon W Maister
febb8dc168 rustfmt everything 2020-06-27 17:04:22 -04:00
Brandon W Maister
77ade72ec8 clippy: match_ref_pats 2020-06-27 16:55:15 -04:00
Brandon W Maister
4837b568c2
Merge pull request #381 from waldyrious/same-to_same-as
Reword 'same to' → 'same as'
2019-12-30 17:17:46 -05:00
Waldir Pimenta
176dfeff87 Reword 'same to' --> 'same as' 2019-12-29 22:27:59 +00:00
Brandon W Maister
b9c967b2ac support round tripping display <-> datetime
This extends `FromStr` to allow either a `T` or a ` ` (space) as the delimiter
between the date and the time, and, because of the fact that the `Z`
parser-specifier is shared with the Fixed notation, extends the fixed notation
to support `UTC` in addition to `Z` as the zero-offset.

IMO this Fixes #147
2019-12-27 13:57:02 -05:00
Brandon W Maister
b553798f86 Support -0000 as a valid UTC tz in rfc2822
This is a time that is commonly set in some environments, and RFC 5322
explicitly clarifies that we should treat -0000 as UTC[1][2] when interpretting
rfc2822.

Fixes #102

[1]: https://github.com/chronotope/chrono/issues/102#issuecomment-557846931
[2]: https://tools.ietf.org/html/rfc5322#section-3.3
2019-11-30 16:48:35 -05:00
Brandon W Maister
6622bdcae7 Replace all uses of try! with question mark
The `?` operator was stabilized in 1.13, this gets rid of a few hundred
deprecation warnings.

Fixes #357
2019-11-23 19:18:08 -05:00
Michal Srb
0b8c248791 Fix build with rust 1.13.0 2019-11-23 23:34:59 +01:00
Michal Srb
05acc869b9 Accept Borrow<Item> as items
The parse::parse and format::format functions accepted Iterator of owned
Items. While it is sometimes convenient to pass in the owned values,
neither of the functions really need to own them, so references would
be enough. The Borrow trait allows us to pass in Iterator over values,
references, boxes, etc.

According to RFC 1105 this is a minor change, because it shouldn't break
any existing code. And chrono is in pre-1.0 version anyway.

This allows us to remove multiple cloned() calls which speeds up parsing
and formating:

 name                                                 control ns/iter  remove-cloned ns/iter  diff ns/iter   diff %  speedup
 datetime::tests::bench_datetime_from_str             712              582                            -130  -18.26%   x 1.22
 datetime::tests::bench_datetime_parse_from_rfc2822   252              244                              -8   -3.17%   x 1.03
 datetime::tests::bench_datetime_parse_from_rfc3339   242              239                              -3   -1.24%   x 1.01
2019-11-23 23:34:59 +01:00
Brandon W Maister
64a28d6812 Remove core_only, cfg-out the format::Item::Owned* variants
This means that a few more features of formatting items don't compile in
non-alloc environments, but they wouldn't have worked correctly anyway.
2019-11-22 15:27:10 -05:00
Christopher Serr
9dc91f78ed Implement Support for no_std
This adds a new `std` feature to chrono that is enabled by default. By
deactivating this feature via `default-features = false` you can now use
chrono in applications that don't use the standard library. The `serde`
feature is supported as well.

Resolves #336
2019-09-07 12:12:49 +02:00
Brandon W Maister
b1592e0e22 Add parse tests for fws and leading-0 to RFC2822 2019-06-24 22:05:06 -04:00
Brandon W Maister
855a894393 Don't warn on deprecated trim functions 2019-03-31 19:03:18 -04:00
Evan Schwartz
11cfb3696e Move NanosecondXNoDot to internal enum
To avoid adding new variants to the public enum (see https://github.com/chronotope/chrono/pull/251#issuecomment-396692148)
2018-06-12 14:53:49 -04:00
Evan Schwartz
937189ee52 Take exactly num digits specified for nanosecond fixed
Error if it's too long or short, and don't take any more digits
2018-06-12 10:51:38 -04:00
Evan Schwartz
8a2b09962a Only parse up to max number of digits for nanoseconds w/o dots 2018-06-12 10:51:38 -04:00
Evan Schwartz
f9d3094d4e Test nanosecond parsing without the dot 2018-06-12 10:51:07 -04:00
Evan Schwartz
1de3658433 Add nanoseconds without dots 2018-06-12 10:51:07 -04:00
Brandon W Maister
c3207a5811 Use the InternalFixed struct for TimezoneOffsetPermissive
It is the backcompat scheme that we have. In the 5.x timeline we will add the
more-standard and significantly-more-pleasant-to-expand `#[doc(hidden)]
__DoNotMatchAgainstMe` trick.
2018-06-07 21:46:57 -04:00
Brandon W Maister
95f6a2be1c Add %#z as "Permissive" timezone parsing
This allows you to parse a timezone that:

* Is either `Z` or an actual offset
* Contains no minutes, just the hour

Fixes #219
2018-06-07 21:46:57 -04:00
Brandon W Maister
c3fa1b5f17 Fix Clippy lints: cast_lossless
Now (assuming clippy is right) all (~100) uses of ` as ` in the code are
actually doing casts that could potentially silently lose data. Woooo?

At least this means that new `as`s can be extra-scrutinized, and we should
probably be adding debug_assert!s for the casts in real code.
2017-10-08 18:12:20 -04:00
Brandon W Maister
268be10d79 Fix Clippy lints: unreadable_literal and inconsistent_digit_grouping
Use `_` consistently in long numeric literals.
2017-10-08 17:38:41 -04:00
Xidorn Quan
0eeb4746f2 fix rfc2822 parsing to allow omitting second 2017-09-19 21:52:07 +10:00
Brandon W Maister
0dc4e3a416 Fix Clippy lints: type_complexity 2017-07-09 15:10:26 -05:00
Kang Seonghoon
7b9b0c4437
Renamed chrono::UTC to chrono::Utc.
Fixes #148.
2017-06-22 00:33:17 +09:00
Kang Seonghoon
c06bc01f0b
Flattened intermediate implementation modules.
There used to be multiple modules like `chrono::datetime` which only
provide a single type `DateTime`. In retrospect, this module structure
never reflected how people use those types; with the release of 0.3.0
`chrono::prelude` is a preferred way to glob-import types, and due to
reexports `chrono::DateTime` and likes are also common enough.

Therefore this commit removes those implementation modules and
flattens the module structure. Specifically:

    Before                              After
    ----------------------------------  ----------------------------
    chrono:📅:Date                  chrono::Date
    chrono:📅:MIN                   chrono::MIN_DATE
    chrono:📅:MAX                   chrono::MAX_DATE
    chrono::datetime::DateTime          chrono::DateTime
    chrono::datetime::TsSeconds         chrono::TsSeconds
    chrono::datetime::serde::*          chrono::serde::*
    chrono::naive::time::NaiveTime      chrono::naive::NaiveTime
    chrono::naive:📅:NaiveDate      chrono::naive::NaiveDate
    chrono::naive:📅:MIN            chrono::naive::MIN_DATE
    chrono::naive:📅:MAX            chrono::naive::MAX_DATE
    chrono::naive::datetime::NaiveDateTime
                                        chrono::naive::NaiveDateTime
    chrono::naive::datetime::TsSeconds  chrono::naive::TsSeconds
    chrono::naive::datetime::serde::*   chrono::naive::serde::*
    chrono::offset::utc::UTC            chrono::offset::UTC
    chrono::offset::fixed::FixedOffset  chrono::offset::FixedOffset
    chrono::offset::local::Local        chrono::offset::Local
    chrono::format::parsed::Parsed      chrono::format::Parsed

All internal documentation links have been updated (phew!) and
verified with LinkChecker [1]. Probably we can automate this check
in the future.

[1] https://wummel.github.io/linkchecker/

Closes #161. Compared to the original proposal, `chrono::naive` is
retained as we had `TsSeconds` types duplicated for `NaiveDateTime`
and `DateTime` (legitimately).
2017-06-21 14:03:49 +09:00
Kang Seonghoon
0ac41c70b1
Minor additions to formatting items.
- Formatting item types are no longer `Copy`.

- `Numeric` and `Fixed` items now have `Internal` variants reserved
  for the future expansion. It had been hard to expand the items
  without totally breaking the backward compatibility (as per
  the API evolution guideline of RFC 1105).

- `Item::Owned{Literal,Space}` for the owned variant of
  `Item::{Literal,Space}` has been added.

Closes #76.
2017-02-07 04:05:05 +09:00
Kang Seonghoon
2b5553ee76 Made Parsed not fully destructible.
So that we can add more fields without breaking a major compatibility
(as per RFC 1105).
2017-02-07 03:14:03 +09:00
Kang Seonghoon
de4df91421
Removed all remaining mentions of rust-chrono (very old name). 2017-02-06 06:15:57 +09:00
János Illés
abdad54884 Use char type instead of single-char Strings
https://github.com/Manishearth/rust-clippy/wiki#single_char_pattern
2016-10-02 01:17:13 +02:00
Kang Seonghoon
00858c6363 More cross-references. 2016-08-02 20:52:45 +09:00
Joe Wilm
097ab04a69 Update RFC850 test to check all weekdays 2016-03-28 09:57:29 -07:00
Joe Wilm
260342a592 Add regression test for RFC850 parsing
Although not supported directly by chrono, users should be able to
specify the RFC850 format and expect it to parse properly. RFC850 is
important since HTTP/1.1 specifies

    HTTP-date = rfc1123-date | rfc850-date | asctime-date
2016-03-28 09:43:52 -07:00
Kang Seonghoon
79686de2d1 Fixed a broken test in 1.7 (missed by the local testing). 2016-03-06 00:32:21 +09:00
Tom Gallacher
b53e9d940f Refactoring matching 2015-09-03 13:43:36 +01:00