Commit Graph

528 Commits

Author SHA1 Message Date
Kang Seonghoon d036c07370
Bincode 1.0.0-alpha2 no longer has the `bincode::serde` module. 2017-02-14 03:28:14 +09:00
Kang Seonghoon 1afa60f377
Test with multiple time zones.
Previously Chrono was mainly tested in UTC (Travis) and UTC+9 (the
maintainer's local time zone), but we have frequently seen bugs that
only appear in time zones behind UTC. This commit makes the test run all
unit tests three times, in different time zones (UTC, UTC+9:30 and
UTC-4 for now---the choice is mostly arbitrary but tries to cover DST
and half-hour offsets for the future). Travis already ran them three
times (for rust-serialize and Serde) so this won't slow the CI down.

Closes #130.
2017-02-14 03:15:07 +09:00
Kang Seonghoon 73a3ec5514
Fixed a bug that the leap second can be mapped wrongly in the local tz.
Turns out to be a relic of pre-FixedOffset offset calculation code. Only
manifests itself when the local time zone is behind UTC.

Fixes #128.
2017-02-14 03:08:24 +09:00
Kang Seonghoon db9b98f691
0.3.0: Planned breaking changes to the existing interface.
So this is a much delayed major release, but this should not really
change how you use Chrono---only the "required" breakages have been
done (e.g. anything hindering API evolution). The "big" release used to
be 0.3, but due to the dependency changes we are forced to push that to
0.4. I've took this opportunity to push all known planned breaking
changes to 0.3, so this should be quite stable for a moment.

See `CHANGELOG.md` for the full list of changes, but most importantly:

- `chrono::prelude` module has been added for proper glob imports.

- `FixedOffset` is now the official "value" type for time zone offsets.

- Serde 0.9 support has landed, and serialization format used by
  rustc-serialize and Serde has been now synchronized.

- Formatting items have been slightly adjusted to be future-proof.

Fixes #126.
2017-02-07 05:52:07 +09:00
Kang Seonghoon 7b17d68474 Fixed warnings in the nightly. 2017-02-07 05:51:56 +09:00
Kang Seonghoon d7d152eff1
Avoid passing nanoseconds to the OS APIs at all. (#123)
Windows still seems to have an issue---it does not accept 60 in the
second field at all. Let's see if not passing it around improves the
situation.
2017-02-07 05:22:12 +09:00
Kang Seonghoon e9e7bdd99c
Removed older aliases (previously marked as deprecated).
The intention was to add newer methods using `std::time::Duration`
to the older names, but it will break the API compatibility anyway.
Better to completely remove them right now.
2017-02-07 04:51:08 +09:00
Kang Seonghoon 96b5ba391b
Fixed a panic when the Local offset receives a leap second.
Fixes #123.
2017-02-07 04:26:29 +09:00
Kang Seonghoon 41d5584900 Merge pull request #114 from tredoe/patch-1
Update mod.rs
2017-02-07 04:12:02 +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 7ea1ce5080
`FixedOffset` is now the official "fixed offset value" type.
This may sound strange, but the final type for the offset "value" was
originally `time::Duration` (returned by `Offset::local_minus_utc`).
This caused a lot of problems becaus adding `Duration` fully interacts
with leap seconds and `Duration` itself is somewhat deprecated.

This commit entirely replaces this role of `Duration` with
`FixedOffset`. So if we had `Offset` and `Duration` to represent
the "storage" offset type and the offset "value" in the past,
we now have `Offset` and `FixedOffset`. Storage-to-value conversion is
called to "fix" the offset---an apt term for the type.

The list of actual changes:

- The time zone offset is now restricted to UTC-23:59:59 through
  UTC+23:59:59, and no subsecond value is allowed. As described above,
  `FixedOffset` is now fully used for this purpose.

- One can now add and subtract `FixedOffset` to/from timelike values.
  Replaces a temporary `chrono::offset::add_with_leapsecond` function.
  Datelike & non-timelike values are never affected by the offset.

- UTC and local views to `Date<Tz>` are now identical. We keep
  relevant methods for the consistency right now.

- `chrono::format::format` now receives `FixedOffset` in place of
  `(Old)Duration`.

- `Offset` now has a `fix` method to resolve, or to "fix" the
  "storage" offset (`Offset`) to the offset "value" (`FixedOffset`).

- `FixedOffset::{local_minus_utc, utc_minus_local}` methods are added.
  They no longer depend on `Duration` as well.
2017-02-07 03:43:59 +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 36c45f2e02 Removed methods deprecated in 0.2. 2017-02-07 03:13:55 +09:00
Kang Seonghoon c118a3985f
Serialization cleanup for 0.3.
- Rustc-serialize now uses the same serialization format as Serde.
  This also means that the older format (naturally derived from
  the internals) is no longer supported.

- Serialization support only existed for rustc-serialize has been
  (temporarily) removed. This affects `Date<Tz>` and all individual
  time zone types. This does *not* affect `DateTime<Tz>` as it has
  individual support per `Tz`.

  Please note that this is considered a temporary solution to avoid
  stabilizing diverging implementations. Their implementations will
  likely be reintroduced later.
2017-02-07 03:08:01 +09:00
Kang Seonghoon c63ef14734
`time::Duration` is no longer the sole duration type described.
Due to the backward compatibility we won't be going to remove support
for `time::Duration` in 0.3, and the initial 0.3.0 release won't have
proper `std::time::Duration` support (haven't finalized the logics).
However we will reserve proper names and signatures for the upcoming
`std::time::Duration` support---the "older" duration type will be
referred as "signed" in the names.

- Added a `chrono::prelude` module. This does not have the (old)
  `Duration` type reexported, so the documentation has now correctly
  replaced all occurrences of `chrono::Duration`. The existing
  `chrono::Duration` reexport itself remains for the compatibility.

- Avoided using a plain `Duration` type in the signature, to avoid
  any ambiguity.

- Renamed `checked_{add,sub}` to `checked_{add,sub}_signed`.

- Subtraction operator between two instants has been removed and
  replaced with `signed_duration_since`. This follows the naming
  chosen by `std::time::SystemTime` etc., and the version for newer
  `std::time::Duration` will be named to `duration_since`.
2017-02-06 09:39:32 +09:00
Kang Seonghoon de4df91421
Removed all remaining mentions of rust-chrono (very old name). 2017-02-06 06:15:57 +09:00
Kang Seonghoon 04fd1413a8
Chrono is now under the Chronotope org; switch to docs.rs.
All CI accounts are now moved to the new organization (unfortunately
Appveyor does not automatically move the build history though).

Since it's a mess to redirect everything to chronotope.github.io,
I've taken this as an opportunity to switch to docs.rs---this seems
to be better than the manual management nowadays.

Updated other files as accordingly.
2017-02-06 05:49:32 +09:00
Kang Seonghoon e9401d9266
Fixed an warning and adjusted CI config for min supported version. 2017-02-06 05:03:01 +09:00
Kang Seonghoon ebdc022045
Added an initial list of categories to Cargo.toml
Closes #118.
2017-02-06 04:38:09 +09:00
Kang Seonghoon 895b92e533 Merge pull request #122 from KodrAus/chore/serde-0.9
Update for serde 0.9
2017-02-06 04:35:01 +09:00
Ashley Mannix 7ed6caa411 set min version to 1.13 2017-02-03 18:00:52 +10:00
Ashley Mannix 66198fbb2e set min version to 1.13 2017-02-03 17:30:17 +10:00
Ashley Mannix 898e266e02 update for serde 0.9 2017-02-01 20:02:22 +10:00
Jonas mg d411f05032 Update mod.rs
Derive trait `Eq` in `ParseError`.
2016-12-08 18:17:26 +00:00
Alex Mikhalev 538f303ed5 Added impl FromStr, Serialize, Deserialize for Weekday 2016-12-06 20:07:39 -07:00
Kang Seonghoon ae7fddc215 Merge pull request #112 from Deedasmi/patch-1
Documentation had the wrong relative path
2016-12-03 16:59:07 +09:00
Richard Petrie d2cd4c9815 Documentation had the wrong relative path
Feel free to destroy this PR and fix in a branch as you see fit.
2016-12-02 12:54:32 -06:00
Kang Seonghoon 0122e5a1a7 Merge pull request #109 from amikhalev/weekday-derive-hash
Added #[derive(Hash)] for Weekday enum
2016-11-15 09:55:09 +09:00
Alex Mikhalev cebb2483d9 Added #[derive(Hash)] for Weekday enum
This is so it can at least be used in a HashSet, if not in a BTreeSet
because it does not impl Ord.
2016-11-14 08:53:58 -07:00
Kang Seonghoon e93d549c5b Merge pull request #108 from quodlibetor/improve-docs
Improve docs around constructing DateTime objects
2016-11-14 00:29:51 +09:00
Brandon W Maister a4c1cc6ed2 Improve docs around constructing DateTime objects
This provides examples for most of the constructor-like methods on
`TimeZone`, examples on the various `Offset` impls, and links
`NaiveDateTime` to `TimeZone` so that it's more obvious how you're
supposed to do things.

This is related to #88, which is something that I ran into when I
started using rust-chrono.
2016-11-12 16:09:08 -05:00
Kang Seonghoon 2dea325524 Merge pull request #101 from jturner314/doc-duration-type
Clarify that Duration is an "accurate" duration
2016-10-05 09:49:57 +09:00
Jim Turner 881e6c2dcc Clarify that Duration is an "accurate" duration
The ISO 8601 format includes both "nominal" (year, month, week, and
day) and "accurate" (hour, minute, and second) components. However, the
`Duration` type only represents an "accurate" duration because
arithmetic with nominal components is not defined in ISO 8601.
2016-10-04 19:07:11 -04:00
János Illés 978b64ff33 support Add/Sub assignment operators for Naive types.
Requires Rust 1.8 or higher.
2016-10-02 15:38:06 +02:00
Kang Seonghoon e308e8e929 Merge pull request #98 from ijanos/clippy
Fix a few clippy warnings
2016-10-02 18:49:13 +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
János Illés 124ff48de8 Remove redundant closure
https://github.com/Manishearth/rust-clippy/wiki#redundant_closure
2016-10-02 01:17:13 +02:00
János Illés 076a54532f Stop using clone() on Copy types
https://github.com/Manishearth/rust-clippy/wiki#clone_on_copy
2016-10-02 01:17:13 +02:00
Kang Seonghoon 6cc5d18696 Merge pull request #89 from dtolnay/bincode
Support deserializing from bincode
2016-08-17 09:45:45 +09:00
David Tolnay c3cd76af16
Add bincode serde tests 2016-08-16 18:08:19 -04:00
Kang Seonghoon 4a3b423527
I'm pretty sure that this fix should bring Appveyor full green.
Observations:

- About 10--15 minutes to complete the CI. Not very bad.

- Travis does not have [skip travis] or similar. Ha.
2016-08-17 03:30:08 +09:00
Kang Seonghoon 8aa1f4b7af
Further tweaks to CI configs.
- Do not doc-test three times in Travis, it simply takes a lot :(

- Forgot that Windows shell doesn't recognize single quotes.
2016-08-17 03:18:12 +09:00
Kang Seonghoon eda83ac3d9
Tweaked Travis settings and tried to enable Appveyor CI. 2016-08-17 03:05:44 +09:00
Kang Seonghoon 582f1166f2
Documentation and complete rewrite for `NaiveDateTime` operations.
- `NaiveDateTime` is now almost completely annotated with examples.

- Introduced `NaiveTime::overflowing_{add,sub}` for the correct
  handling of overflow/underflow of `NaiveTime`.

- `NaiveDateTime +/- Duration` operation is rewritten with those
  methods, eliminating any problem against leap seconds. (Thus this
  is yet another slight breaking change, but considered a bug fix.)
2016-08-17 00:41:08 +09:00
David Tolnay c3b9a26bb0 Support deserializing from bincode
Bincode is a minimal format that expects the Deserialize
implementation to tell it what type of data it should
expect to see.
2016-08-16 02:54:14 -04:00
Kang Seonghoon 8b382fca45
Incremental doc updates for `NaiveDateTime`.
Also moved the leap second arithmetic examples to
`chrono::naive::time`, as it became hard to link from other pages.
2016-08-16 02:15:56 +09:00
Kang Seonghoon 0393cae36d Standardized the doc example format for shortened methods.
Especially for naives types, methods can be too long to fit in
one line. Previously ad-hoc closures have been used for extreme
cases; this commit will update them to the following form:

    use anything::needs::to::be::imported;

    let shortened = SomeType::long_name_to_be_shortened;

    assert_eq!(shortened(...), ...);

It should be noted that the shortened name is no longer arbitrary;
it should be either the original method name, or when it gets too
long, a name with adjectives and clauses removed. The abbreviation
is now consistent, and restricted to the following:

- `num_days` -> `ndays`; `num_secs` -> `nsecs`
- `hms_milli` -> `hmsm`; - `hms_micro` -> `hmsu`; `hms_nano` -> `hmsn`

The goal is to make examples NOT look alike tests, and more alike
the actual code. (Well, not always possible but I'm trying.)
2016-08-08 03:34:00 +09:00
Kang Seonghoon 62d289fc85 Added documentations for `NaiveTime` and `NaiveDateTime` methods.
Also slightly edited the `format` and `format_with_items` docs to be
more unobstructive (i.e. implicit `use` from previous blocks).
2016-08-08 03:04:39 +09:00
Kang Seonghoon 69d7a86c1c Subtraction fixes for NaiveTime.
Again, this time with more thorough tests and documentation.
2016-08-07 02:32:09 +09:00
Kang Seonghoon d50546a592 More documentation for NaiveTime, and addition fixes.
While writing documentation tests for NaiveTime it was found that
the addition involving leap seconds is *still* slightly broken.
(A consequence of having less tests, well.) The addition routine
has been rewritten to be explicit about leap seconds while passing
all other tests, so the rewrite does not change the intention.
2016-08-06 19:32:01 +09:00