`Time` with an associated time zone is in principle possible, but
in practice it can only meaningfully constructed from an existing
`DateTime`. this makes it hard to implement other operations
natural to `NaiveTime` for `Time` (e.g. `with_*` methods), so
we simply let it go.
migration path: if you *do* happen to use `Time`, don't panic!
every operation possible to `Time` is much more possible to
`NaiveTime`. if you have to deal with a local time, first combine
it with a `NaiveDate`, convert it via `TimeZone::from_local_datetime`
then extract `Time` part again.
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.
- We have splitted `Offset` into `Offset` and `OffsetState` (name
changes in consideration). The former is used to construct and convert
local or UTC date, and the latter is used to store the UTC offset
inside constructed values. Some offsets are their own states as well.
- This uses lots of associated types which implementation is still in
flux. Currently it crashes with debuginfo enabled. We've temporarily
disabled debuginfo from `Cargo.toml`.
- This technically allows a conversion to the local time, but not yet
tested.
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.
- Every type modulo `LocalResult` and `Offset` now implements
`std::fmt::String`, so `.to_string()` can be used.
The exact format has been changed for better looking output.
- `std::fmt::Show` are intended for "stricter" output,
which mostly means the strict ISO 8601 format.
`DelayedFormat` also implements this, but only for inspection.
- `Offset` should implement `Show` but can omit `String`.
The old `name` method is merged into `String` implementations.
- Feature flags used are all accepted.
- Orphan check workaround is no longer required.
- Impl reachability rules prevent the addition of `Duration + others`,
as `Duration` is not implemented in this crate. Removed the impl;
use `others + Duration` as a workaround.
- #[deriving] is now #[derive].
- prelude no longer imports many items by default.
- [T, ..n] is no longer valid.
- a temporary fix for #[derive(Hash)] failing out.
- the formatting error uses a dedicated type instead of `IoError`.
Added 'use' statements for cmd::Ordering, ops::{Add, Sub}, borrow::IntoCow, num::ToPrimitive
Changed deriving -> derive. Changed [x, ..N] -> [x; N].
Made format(f: &fmt::Formatter) return fmt::Result instead of
IoResult. Had to raise generic errors in a couple of cases where
IoResult's fields were being set (but these errors were being thrown
out anyway).
Temporarily set #![feature(old_orphan_check)] because
Thanks for @eddyb for explaining the format() situation.