Commit Graph

556 Commits

Author SHA1 Message Date
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 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
Brandon W Maister 918cff1f72 Remove some pwds from the CI script
They just add noise, now.
2019-09-20 13:49:30 -04:00
Brandon W Maister 6499c5b1c9 Using core-only on 1.13 doesn't seem to work the same as stable 2019-09-20 13:49:01 -04:00
Brandon W Maister 911dc57402 support rust v1.13.0 struct initialization syntax 2019-09-20 11:41:23 -04:00
Brandon W Maister 9e50bfe034
Merge pull request #344 from quodlibetor/extract-num-days-from-epoch
Add Datelike::num_days_from_epoch
2019-09-20 11:22:58 -04:00
Brandon W Maister 9a3e48931b Make ci script more understandable and robust, hopefully 2019-09-20 11:19:43 -04:00
Brandon W Maister ffcd0f9c19 put bincode back to the version used for testing 2019-09-20 11:02:00 -04:00
Brandon W Maister a09f9ba2a8 Test against serde with no features in both std and no-std 2019-09-20 10:50:28 -04:00
Brandon W Maister 505db4504d Add Datelike::num_days_from_epoch 2019-09-18 17:48:39 -04:00
Brandon W Maister e5bbc94c3b First pass at making "alloc" its own feature
Part of this means that we don't actually need to allocate to write to Serde
any more, which is a win in its own right.
2019-09-15 20:45:49 -04:00
Brandon W Maister 5b72ef3ed6 Make travis.sh and Makefile "nicer"
Slightly easier to reason about the code via some code movement, printing some
banners to make it more obvious when cargo is being run since it is run so many
times.
2019-09-15 20:44:37 -04:00
Brandon W Maister e8c708d81b Make CI able to run non-cargo commands in `channel` 2019-09-13 15:50:20 -04:00
Brandon W Maister 5e1e2d5633 Add a trivial function in core test
To ensure that we don't accidentaly not verify that chrono compiles for core.
2019-09-13 14:50:14 -04:00
Brandon W Maister 4027bbb66d Rename serde-1 back to serde 2019-09-13 14:49:41 -04:00
Christopher Serr e62a054cd9 Introduce an `alloc` feature 2019-09-09 13:51:10 +02:00
Christopher Serr 5ccec02e54 Use std in all other tests on CI 2019-09-07 12:24:11 +02: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 bbfcfad44f
Merge pull request #338 from chronotope/wasm-pack-test
Wasm pack test
2019-09-03 23:02:34 -04:00
Brandon W Maister be93229271 Bump Chrono version to 0.4.9 2019-09-03 22:30:39 -04:00
Brandon W Maister 4617e2e5ba Make the wasm-pack tests actually run 2019-09-03 22:30:39 -04:00
Brandon W Maister c045750e06
Merge pull request #335 from chronotope/fix-wasm
Put wasm-bindgen and js-sys behind a wasm-bindgen feature gate
2019-09-03 22:12:39 -04:00
Brandon W Maister 2839d8d7db Put wasm-bindgen and js-sys behind a wasm-bindgen feature gate
Fixes #334
2019-09-03 09:05:15 -04:00
Brandon W Maister b1337fc123
Merge pull request #337 from chronotope/fix-addition-with-timezones
Adjust timezones after doing Duration addition
2019-09-03 08:08:32 -04:00
Brandon W Maister 371cf6d29b Adjust timezones after doing Duration addition
The internal, tz-independent timestamp was valid, but since the timezone offset
could change as you add or subtract a second or two you would get
nonsense/nonexistent times when you observed them.

Fixes #318
2019-09-02 14:58:54 -04:00
Brandon W Maister 630cade52a
Merge pull request #333 from chronotope/v0.4.8
v0.4.8
2019-08-31 16:34:25 -04:00
Brandon W Maister 6ce91fbfbb allow deprecated inclusive range patterns
We still support ancient Rust.
2019-08-31 15:40:11 -04:00
Brandon W Maister a70c5cdc79 Bump Chrono version to 0.4.8 2019-08-31 15:26:32 -04:00
Brandon W Maister 6429cd2780 Add CHANGELOG entry for wasm-unknown-unknown
Features added in #287 and #331
2019-08-31 15:22:01 -04:00
Brandon W Maister 3e180b711e
Merge pull request #331 from evq/wasm
basic wasm support
2019-08-23 15:54:20 -04:00
eV cc073a650f remove cargo web / compile time error 2019-08-22 08:09:56 +00:00
eV f21b1fbf21 Fix emscripten and guard against cargo test + wasm32-unknown-unknown 2019-08-16 22:46:10 +00:00
eV f52a29398c one more guard 2019-08-16 21:10:55 +00:00
eV e28719eb0d try to get travis working for rust 1.13.0 2019-08-16 21:04:07 +00:00
eV bd22644b05 only use nvm on mac 2019-08-16 20:04:45 +00:00