Commit Graph

40 Commits

Author SHA1 Message Date
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
Kang Seonghoon cb9fd7fbe1 0.2.25: Fixed warnings from 0.2.24. Duh. 2016-08-04 03:44:31 +09:00
Kang Seonghoon ad6253f653 Proper (de)serialization format handling.
For a while Chrono's serialization support was barely working,
i.e. usable but never been safe. While it wouldn't cause any memory
unsafety, attacker can fabricate an input that will make most users
confused (e.g. seemingly same Date which doesn't compare equally).
This commit will properly error for those cases.

It was also problematic that the generated rustc-serialize format is
very inefficient, especially for JSON. Due to the backward
compatibillity this commit does NOT fix them (likely to be in 0.3),
but this does try to define the exact format and define tons of
tests to detect any change to the serialization.

There are several remaining problems in the serialization format;
the serde implementation seems good, but it is unable to distinguish
some cases of leap seconds (practically won't matter, but still).
The rustc-serialize implementation would require a massive redesign.
For now, I postpone those issues to 0.3 (what a convenient excuse).

Fixes #42.
2016-08-04 03:22:12 +09:00
Kang Seonghoon 4475ee5a48 More cross links and detailed examples for docs.
Also fixed some broken links (hard to catch from source files).
2016-08-01 03:23:46 +09:00
Kang Seonghoon 932e29aa94 Better documentation and cross-references for naive types. 2016-08-01 01:02:32 +09:00
Kang Seonghoon 66d5856354 Fixed `%.[369]f` on the whole seconds and misleading docs.
Fixes #71.
2016-04-22 00:47:01 +09:00
Ryan Lewis f8630fce81 Update serde to 0.7.0
rename visit_str to serialize_str
rename E::syntax(&str) to E::Custom(String)
rename deserializer.visit to deserialize.deserialize
2016-03-03 20:54:47 +13:00
Martin Risell Lilja d8f2a3e7d8 Added serde support for DateTime, NaiveDate, NaiveTime and NaiveDateTime. 2015-11-19 00:12:13 +01:00
Kang Seonghoon 24bc15fdd3 more documentation for `NaiveTime`; some terminology updates. 2015-09-12 02:41:38 +09:00
Kang Seonghoon acf4eab102 more documentation, finishing examples for chrono::naive::date. 2015-09-06 21:30:09 +09:00
Kang Seonghoon 5ff21f4077 fixed a subtle bug for `Naive(Date)Time + Duration`. (#37)
The exact condition is that the `Duration` to be added is negative
and has a fractional second part. This was not a problem when
`Duration` was Chrono's own type, but a new code for external (then
libstd, now libtime) `Duration` was not tested for this condition
by accident. Consequently this condition caused an underflow in
the fractional part, resulting in a slight inaccuracy.

Fixes #37.
2015-05-15 02:06:34 +09:00
Jisoo Park b5281af9f3 Add optional rustc-serialize support 2015-04-28 18:42:18 +09:00
Kang Seonghoon 9ed34ec542 0.2.9: language changes.
- `std::num::Int` is deprecated.

- Removed one feature flag (`str_char`).
2015-04-03 17:53:44 +09:00
Dan d85ca7564f Remove old closure kind syntax 2015-03-02 11:50:03 +00:00
Kang Seonghoon c11b6deb5a 0.2.1: language changes.
- `std::hash` has been renewed.

- `DelayedFormat` no longer has a redundant lifetime.
2015-02-21 18:15:11 +09:00
Kang Seonghoon 664c4d0191 merged the new offset design branch. 2015-02-19 01:48:29 +09:00
Kang Seonghoon a4f5d19d24 mass renaming from offset/state to timezone/offset. 2015-02-19 00:30:13 +09:00
Kang Seonghoon 76b0873722 added `FromStr` impls to naive date and time types.
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.
2015-02-18 23:27:12 +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 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 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 e97993d76a 0.1.11: language changes.
- Boxed closures are gone; some unboxed closures require an explicit
  annotation for kinds (`&:` in most cases).
2015-01-06 22:38:37 +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 ec6c874042 language changes: namespaced enums, no more std::num::{Zero,Bounded}. 2014-11-19 10:59:32 +09:00
Kang Seonghoon 10c580f664 switches to std::time::duration::Duration. 2014-08-31 14:43:26 +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 ed71a1037b made `Time::fmt` to use the same decimal separator as `Duration::fmt`. 2014-07-31 11:03:32 +09:00
Kang Seonghoon 9d52c6d2f1 added constructors from timestamp; added `UTC::{today,now}`. 2014-07-31 10:09:54 +09:00
Kang Seonghoon 95f5c0c095 splitted naive types into their own modules. 2014-07-29 16:17:26 +09:00