Commit Graph

130 Commits

Author SHA1 Message Date
Kang Seonghoon 46996e35e1 implemented `FromStr` for `DateTime<FixedOffset/UTC>`. 2015-02-19 00:03:58 +09:00
Kang Seonghoon 637784c8ef renamed `from_str` methods to `parse_from_str`.
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.
2015-02-15 21:27:12 +09:00
Kang Seonghoon c7f132cca2 added `format_with_items` methods to every types. 2015-02-14 12:34:31 +09:00
Kang Seonghoon 7eb9a1a983 public interfaces for parser are now available. 2015-02-05 02:16:35 +09:00
Kang Seonghoon 3d00a0fd5a added `checked_{add,sub}` methods to `[Naive]Date[Time]` types.
- Existing `+` and `-` operators use them, and properly panics with
  a correct error message on overflow/underflow.
2015-02-04 16:19:54 +09:00
Kang Seonghoon 43ee68b522 new formatter design!
- 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.
2015-02-04 16:19:54 +09:00
Kang Seonghoon cf5e2f322f 0.1.15: language changes.
- `std::fmt::Show` is now `std::fmt::Debug`.
- `std::fmt::String` is now `std::fmt::Display`.
2015-01-24 17:45:12 +09:00
Kang Seonghoon 45765ebd13 0.1.14: fixed a missing `String` impl for `Local`.
Fixes #20. Thanks to @daboross.
2015-01-10 12:32:54 +09:00
Kang Seonghoon ca84749869 0.1.13: language changes and fmt::String supports.
- 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.
2015-01-10 03:27:24 +09:00
Kang Seonghoon d79c460fc4 0.1.12: language changes, removed ops for Duration in the lhs.
- 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.
2015-01-08 02:08:41 +09:00
Kang Seonghoon e2ddee2f76 0.1.9: language changes.
- `Add` and `Sub` switches to associated types.
2015-01-05 18:31:15 +09:00
Kang Seonghoon cde432ed8e bumped copyright years. 2015-01-04 15:08:25 +09:00
Ken Tossell 3303127415 Fixed build against rust nightly.
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.
2015-01-03 17:45:07 -05:00
Kang Seonghoon e982cd1851 0.1.5: language changes.
- Add and Sub requires a value instead of a reference.
- Tuple indexing is now ungated.

Fixes #15.
2014-12-17 10:29:48 +09:00
klutzy 37d85ffd3b Update for upstream changes 2014-12-13 20:29:06 +09:00
Kang Seonghoon 920a681d54 better documentation, some additional APIs.
- `Date/Time - Duration` is now supported. (duh!)
- `with_offset` methods have been added.
- `LocalResult` now implements common traits.
- `LocalResult` has several methods to propagate errors.
  this makes the initialization from untrusted sources easier
  (`off.ymd_opt(y,m,d).and_hms_opt(h,n,s).single()`).
2014-11-28 23:53:22 +09:00
Kang Seonghoon 86665d0a7f 0.1.2: no more `num` dependency, multidispatched addition.
- `num` dependency is gone. It was only used for floored division
  and it is not hard to copy only that portion from num.
- `Duration + Date` (or so) was blocked by rust-lang/rust#7590,
  which has been subsequently fixed.
- Removed unused `unsafe` checks.
2014-11-24 14:52:07 +09:00
Kang Seonghoon 10c580f664 switches to std::time::duration::Duration. 2014-08-31 14:43:26 +09:00
Kang Seonghoon 80ed400689 added missing `.offset()` methods; UTC/FixedOffset now implement Eq. 2014-08-29 18:14:08 +09:00
Kang Seonghoon f1931ad21e added `chrono::format` module and `format` methods.
this is a saner replacement for `time::strftime`; it does not allocate
the additional memory.
2014-08-01 04:08:19 +09:00
Kang Seonghoon 95f5c0c095 splitted naive types into their own modules. 2014-07-29 16:17:26 +09:00
Kang Seonghoon 586b41df54 mass renaming from `BlahBlahZ` to `NaiveBlahBlah`. 2014-07-29 15:55:40 +09:00
Kang Seonghoon 32c3ee85e8 initial `Offset` implementations. 2014-07-29 15:41:47 +09:00
Kang Seonghoon 07d98709df fixed a bug on `DateTimeZ::add` with the negative fractional `Duration`. 2014-07-29 15:38:24 +09:00
Kang Seonghoon c7c3052892 made every type `Clone`able; added `and_*` constructors to `DateZ`.
it allows for, say, `DateZ::from_ymd(2014,1,2).and_hms(3,4,5)`.
2014-07-29 15:36:35 +09:00
Kang Seonghoon d5f652e656 renamed `n<foo>s` to `num_<foo>s` and changed their semantics.
`Duration` now has a `to_tuple` method which corresponds to
the original `(dur.ndays(), dur.nseconds(), dur.nnanoseconds())`.
new `num_*s()` methods in `Duration` always return the integral
number of specified units in the duration.

cf. rust-lang/rust#15934
2014-07-25 21:00:32 +09:00
Kang Seonghoon 4dbd00dca2 added all missing docs. 2014-07-25 18:12:51 +09:00
Kang Seonghoon b79f6b302b major API surgeries.
- added a new example.
- reexported all public APIs in the crate root.
- made all constructors fail on the invalid arguments by default;
  `*_opt()` variants have been added for the original behavior.
- same for `DateZ::{succ,pred}`.
- fixed a missing overflow check from `TimeZ::from_hms_{milli,micro}`.
2014-07-20 02:51:57 +09:00
Kang Seonghoon dce4ec8f45 the public API now uses i32/u32 instead of int/uint for integers.
closes #1.
2014-07-20 02:00:33 +09:00
Kang Seonghoon b5a2340214 updated .travis.yml to use install.sh for Cargo; src/chrono -> src. 2014-07-15 13:20:48 +09:00