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).
- 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.
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.
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`.
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.
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
- Padding modifiers `%_?`, `%-?` and `%0?` are implemented.
They are glibc extensions which seem to be reasonably widespread
(e.g. Ruby).
- Added `%:z` specifier and corresponding formatting items
which is essentially same to `%z` but with a colon.
- Added a new specifier `%.f` which precision adapts from the input.
Also clearly documented the differences between `%f` and `%.f`. (#40)
- The time zone offset is printed without a colon, but the documentation
had that inverted. (#39)
- `chrono::format::strftime`'s specifier table is tested throughly.
- When `%s` specifier is used with a time zone, the time zone offset was
ignored. This has been fixed.
- Feature flags are now required on the doctests.
- New lints for trivial casts. We are now not going to change
the internal implementation type for `NaiveDate`, so that's fine.
this is partly because... we are using the simple name `timestamp`
in the `Parsed` anyway. that value is so widespread enough that
its name can be simply THE timestamp. old methods have been marked
deprecated.
also, previously `Numeric::Nanosecond` had a special left-aligned
parsing behavior. this commit replaces that with a newly designated
`Fixed::Nanosecond` which also handles an empty string which is
possible with an integral number of seconds.
this is most importantly required for negative years in `Parsed`,
which the current parser doesn't generate but is nevertheless
possible in principle. also updates tests for new fields.
so that we can safely implement `FromStr` traits for those types.
also updates READMEs and rewires `%+` specifier of `StrftimeItems`
to a new RFC 3339 formatting item.
this new module encompasses John Nagle's original RFC 2822 and 3337
parsers, updated to fully compatible to the actual standard.
the contributed `parse` module has been merged into it.
also changes the behavior of `Numeric::Nanosecond` (`%f`) to
the left-aligned digits and allows for the wider range of time zone
offsets from -99:59 to +99:59.
Basically, this should close#12 when officially released.
- Formatting syntax is now refactored out of the rendering logic.
The main syntax is available in the `format::strftime` module,
which also serves as a documentation for the syntax.
- A parser (modelled after `strptime(3)`) has been implemented.
See the individual commits for the detailed implementation.
- There are two ways to get a timezone-aware value from a string:
`Offset` or `DateTime<FixedOffset>`. The former should be used
when the offset is known in advance (e.g. assume the local date)
while the latter should be used when the offset is unknown.
Naive types have a simple `from_str` method.
- There are some known problems with the parser (even after
tons of tests), which will be sorted out in 0.2. Known issues:
- This does not exactly handle RFC 2822 and RFC 3339, which
subtly differs from the current implementation in
case-sensitivity, whitespace handling and legacy syntax.
I'd like to integrate #24 for this cause.
- Time zone names are not recognized at all. There is even
no means to get a name itself, not sure about the resolution.
- `Parsed` does *not* constrain `year` to be non-negative,
so manually prepared `Parsed` may give a negative year.
But the current verification pass may break such cases.
- I absolutely don't know about the parser's performance!
- `AUTHORS.txt` has been added, for what it's worth.
- Format string is internally represented as a series of formatting
items. Items can be directly given to now-public `format::format`
function as well.
- Format string parser is separated to `format::strftime` module.
This is to allow for potentional alternative formatting syntaxes.
- `DelayedFormat` now receives an iterator for formatting items.