Commit Graph

591 Commits

Author SHA1 Message Date
Brandon W Maister b9cd0ce803
Merge pull request #270 from asayers/from_ymwd
Construct a NaiveDate by specifying eg. "the 2nd Friday of March 2017"
2019-12-26 20:17:17 -05:00
Brandon W Maister 5d16648df4 rename from_ymwd -> from_weekday_of_month 2019-12-23 17:33:44 -05:00
Brandon W Maister b5015c634b
Merge pull request #348 from gThorondorsen/test-num_days_from_ce
Test `Datelike::num_days_from_ce` against an alternative implementation
2019-12-23 17:19:43 -05:00
Brandon W Maister d9d0728f51
Merge pull request #374 from quodlibetor/fix-playground-and-docs
Change docs and playground features so that it compiles
2019-12-23 14:16:02 -05:00
Brandon W Maister 6daed98412
Merge pull request #376 from AnderEnder/remove-deprecated-error-description
Allow deprecated Error::description and replace it with a stub implementation.
2019-12-23 13:48:56 -05:00
Brandon W Maister 536ac86511 Add bench for new implementation
Unfortunately it seems to be slightly more than twice as slow. On the plus
side, that is some justification for the existing optimizations.
2019-12-23 13:46:45 -05:00
Gwaihir Thorondorsen 3e592d4565 Test `Datelike::num_days_from_ce` against an alternative implementation 2019-12-23 13:28:46 -05:00
Brandon W Maister 5ca6ff5afc Make it harder to accidentally use private features
In particular if built with `--all-features` or `features = "all"` we don't
want to accidentally make it look like `YearFlags` are something that people
should use. So: hide it from docs and put it behind a dunder.
2019-12-23 13:26:05 -05:00
Brandon W Maister 4f73f9423b Make criterion a dev dependency
It's much less risky than making it an optional dependency, even if it does
mean that everyone working on chrono has to compile it.
2019-12-23 12:51:11 -05:00
Brandon W Maister 977ad60391 allow_deprecated on stub Error::description for rust 1.13 2019-12-23 12:38:25 -05:00
Andrii Radyk a42c5b22cd remove deprecated Error::description 2019-12-17 09:42:32 +01:00
Brandon W Maister a5e2796931 Change docs and playground features so that it compiles
All features includes some things that are nightly only.

Fixes #373
2019-12-13 11:10:49 -08:00
Brandon W Maister df0e6ae8f6
Merge pull request #370 from quodlibetor/rfc2822-is-http-and-email
Document that rfc2822 is what is used for http and email headers
2019-11-30 19:46:05 -05:00
Brandon W Maister 495243ae3c
Merge pull request #369 from quodlibetor/finish-criterion
Finish moving all benchmarks to criterion
2019-11-30 19:45:37 -05:00
Brandon W Maister d0dbc61b69 Make criterion an optional dependency
So that it doesn't slow down every user's builds and and CI
2019-11-30 18:40:28 -05:00
Brandon W Maister 7a1cd09b86 Document that rfc2822 is what is used for http and email headers
Closes #328
2019-11-30 18:25:36 -05:00
Brandon W Maister 4f1c35827f Finish moving all benchmarks to criterion
I didn't delete some, apparently, and an internal struct had to be made public
to get its benchmark to work.
2019-11-30 18:11:03 -05:00
Brandon W Maister b10e430b1f
Merge pull request #368 from quodlibetor/support-negative-utc-in-rfc2822
Support -0000 as a valid UTC tz in rfc2822
2019-11-30 17:59:22 -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 19dd051d22
Merge pull request #365 from coolreader18/fix-wasi
Add support for compilation on wasm32-wasi
2019-11-29 15:03:27 -05:00
Brandon W Maister 00e6edd457
Merge pull request #367 from quodlibetor/0_4_10-compat-notes
Add compatility notes about the new alloc feature in 0.4.10
2019-11-29 15:01:00 -05:00
Brandon W Maister 3532e33ac2 Add compatility notes about the new alloc feature in 0.4.10
Closes #364
2019-11-29 14:19:22 -05:00
Brandon W Maister 596aa19104
Merge pull request #363 from quodlibetor/use-criterion-benchmarks
switch to using criterion for benchmarks
2019-11-29 14:06:43 -05:00
coolreader18 c5973277e7
Don't do wasmbind on wasi 2019-11-26 23:57:51 -06:00
Brandon W Maister 80da04381c add serialization benchmark 2019-11-24 15:05:47 -05:00
Brandon W Maister 8de2cc375f switch to using criterion for benchmarks
It has a ton of great features[1], including stronger statistical signifance
tests, making comparisons to previous or baseline runs, nice plots, and being
able to be run on stable.

1: https://bheisler.github.io/criterion.rs/book/
2019-11-24 13:51:27 -05:00
Brandon W Maister 59059352c1
Merge pull request #361 from quodlibetor/deny-dead-code
Remove unused constant, deny(dead_code)
2019-11-24 12:15:55 -05:00
Brandon W Maister 41700d101e Remove unused constant, deny(dead_code) 2019-11-23 19:58:20 -05:00
Brandon W Maister 5b4fc23bcb
Merge pull request #360 from quodlibetor/chrono-0_4_10
Prepare for and Bump Chrono version to 0.4.10
2019-11-23 19:53:58 -05:00
Brandon W Maister 288f1dd76f
Merge pull request #356 from quodlibetor/num_days_from_epoch-docs
Remove num_days_from_epoch
2019-11-23 19:29:23 -05:00
Brandon W Maister 670561b4c1 Prepare for and Bump Chrono version to 0.4.10 2019-11-23 19:19:04 -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
Brandon W Maister 46f8267c61
Merge pull request #358 from michalsrb/optimize-parsing
Optimize parsing
2019-11-23 19:09:12 -05:00
Brandon W Maister b717e0442c Handle some semantic merge conflicts
Something that wasn't part of this PR: the work to support nested
`Option<[ChronoType]>` was merged without being adjusted for the no-std
support

And now there are some unused import warnings because they need to get
configged out.
2019-11-23 18:38:38 -05:00
Brandon W Maister 27f5e5e9b3 Temporarily globally allow deprecated
The question mark will be fixed in a pending commit
2019-11-23 18:22:40 -05:00
Michal Srb 0b8c248791 Fix build with rust 1.13.0 2019-11-23 23:34:59 +01:00
Michal Srb a716b48e9d Inline some parse related functions
Speedups:
 datetime::tests::bench_datetime_from_str             365                         337                       -28   -7.67%   x 1.08
 datetime::tests::bench_datetime_parse_from_rfc2822   195                         181                       -14   -7.18%   x 1.08
 datetime::tests::bench_datetime_parse_from_rfc3339   166                         142                       -24  -14.46%   x 1.17
2019-11-23 23:34:59 +01:00
Michal Srb 6da5359d39 Reimplement scan::number
The original would first check that there is right amount of numeric
characters and then parsed them using the std::str::parse, which
internally checks the characters again and also checks for -/+ prefix,
which is not necessary in this case.

Since we are already going over the characters, we may as well do the
parsing ourselves. The length of the function is roughly the same and
it is faster:

 name                                                 simplify-from-str ns/iter  reimplement-number ns/iter  diff ns/iter   diff %  speedup
 datetime::tests::bench_datetime_from_str             448                        365                                  -83  -18.53%   x 1.23
 datetime::tests::bench_datetime_parse_from_rfc2822   242                        195                                  -47  -19.42%   x 1.24
 datetime::tests::bench_datetime_parse_from_rfc3339   234                        166                                  -68  -29.06%   x 1.41
2019-11-23 23:34:59 +01:00
Michal Srb f7318277e2 Simplify ITEMS in FromStr implementations
The Item::Space calls str::trim_left and Item::Numeric also calls
str::trim_left before doing anything else, so there is no need to
have Item::Space before Item::Numeric.

Speeds up parsing:
 name                                                 remove-cloned ns/iter  simplify-from-str ns/iter  diff ns/iter   diff %  speedup
 datetime::tests::bench_datetime_from_str             582                    448                                -134  -23.02%   x 1.30
 datetime::tests::bench_datetime_parse_from_rfc2822   244                    242                                  -2   -0.82%   x 1.01
 datetime::tests::bench_datetime_parse_from_rfc3339   239                    234                                  -5   -2.09%   x 1.02
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
Michal Srb 53ef941c3a Add benchmarks for DateTime parsing and formatting 2019-11-23 23:34:59 +01:00
Michal Srb db8784f97c Fix existing benchmarks
The #[cfg(bench)] attribute does not exist and is always false. Lets
define a feature "bench" which can be used to enable benchmarks when
building with nightly.
2019-11-23 23:34:59 +01:00
Brandon W Maister d9929a60b4
Merge pull request #341 from CryZe/no-std
Implement Support for no_std
2019-11-22 16:53:09 -05:00
Brandon W Maister 3d385fe2ce
Merge pull request #302 from manifest/feature/option
Add Serialize/Deserialize for Option<DateTime>
2019-11-22 16:07:09 -05:00
Brandon W Maister 7dd7f0c6e7
Merge pull request #359 from quodlibetor/markdown-footnotes
Use markdown footnotes in strftime docs
2019-11-22 15:43:39 -05: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
Brandon W Maister 6a2adc45b7 Use markdown footnotes in strftime docs 2019-11-22 11:30:10 -05:00
Brandon W Maister a74a9744f1 Remove num_days_from_epoch
Deciding between zero-indexed (slightly more reasonable, more compatible with
the outside world) and one-indexed (same indexing as `num_days_from_ce`) seems
not worth it. It's trivial to build `num_days_from_epoch` based on the docs in
`num_days_from_ce`, which punts on the decision and is therefor probably the
right decision.
2019-11-16 16:48:47 -05:00
Brandon W Maister 8e6bc299f8
Merge pull request #349 from gThorondorsen/fix/347
Improve documentation of `num_days_from_ce` methods
2019-11-16 15:17:01 -05:00
Gwaihir Thorondorsen bfdef11d0b Clarify documentation of `num_days_from_ce` methods
The new wording tries to make clearer that those methods use a 1-based
numbering scheme.

This commit also includes a couple of drive-by cosmetic changes.
2019-10-08 19:04:43 +02:00