1371 Commits

Author SHA1 Message Date
Charles Samborski
ccd3737bcc Add DateTime::<Utc>::from_timestamp
This commit adds the new constructor `from_timestamp` to build a `DateTime<Utc>` from a UNIX timestamp.

Figuring out how to convert a timestamp into a `DateTime<Utc>` was a common issue:
- https://github.com/chronotope/chrono/issues/88
- https://github.com/chronotope/chrono/issues/200
- https://github.com/chronotope/chrono/issues/832

This commit should make `DateTime<Utc>` creation more discoverable and intuitive.

This commit respects the current convention of preferring fallible functions. It avoids however the `_opt` suffix as there is no panicking variant. See [this issue](https://github.com/chronotope/chrono/issues/815) for discussion about error handling and panics.

Closes https://github.com/chronotope/chrono/issues/832
2023-09-11 10:32:18 +02:00
Paul Dicker
90a9913cf8 CI: remove exception for __doctest feature in cargo hack check 2023-09-11 09:22:50 +02:00
Paul Dicker
155e9da327 Make dependabot target 0.4.x branch 2023-09-11 09:22:50 +02:00
Paul Dicker
85d4f7f590 Bump actions/checkout from 3 to 4 2023-09-11 09:22:50 +02:00
Paul Dicker
2960f2c454 Remove __doctest feature 2023-09-09 11:33:17 +02:00
Paul Dicker
77d0bec82d Add more documentation about the RFC 2822 obsolete date format 2023-09-08 11:44:13 +02:00
Paul Dicker
101ca7e96d Bump version to 0.4.30 v0.4.30 2023-09-07 16:46:53 +02:00
Dirkjan Ochtman
eee59e373a Rewrite history sections for clarity and consistency 2023-09-07 13:14:53 +02:00
Paul Dicker
7387fe7aba Add history of chrono and time 0.1 to main documentation 2023-09-07 12:28:01 +02:00
Paul Dicker
8509da4979 Apply Clippy suggestions for duration module 2023-09-07 10:28:10 +02:00
Paul Dicker
9d7fafe69b Remove mention of oldtime from documentation 2023-09-07 10:28:10 +02:00
Paul Dicker
27ea7e9007 Rename oldtime module to duration 2023-09-07 10:28:10 +02:00
Paul Dicker
8f5becd277 Drop time 0.1 as optional dependency 2023-09-07 10:28:10 +02:00
Paul Dicker
f4aefc7f33 Clarify Timelike::num_seconds_from_midnight is a simple mapping 2023-09-06 17:04:30 +02:00
Paul Dicker
1903778a15 Add NaiveDate::leap_year 2023-09-06 17:02:01 +02:00
Truong Tan Dat
84334df989 Update readme 2023-09-06 16:20:56 +02:00
Paul Dicker
8509c25364 Bump version to 0.4.29 v0.4.29 2023-09-05 17:34:32 +02:00
Dirkjan Ochtman
d7444990b7 Add Discord link to README 2023-09-05 15:24:15 +02:00
Paul Dicker
2a96a795ca Deprecated TimeZone::datetime_from_str 2023-09-05 14:23:14 +02:00
Paul Dicker
754ad18ed3 Remove remaining uses of TimeZone::datetime_from_str() from tests and docs 2023-09-05 14:23:14 +02:00
Paul Dicker
935e7b5953 Parse to NaiveDateTime in parse_rfc850 test
The format string doesn't contain any offset info.
2023-09-05 14:23:14 +02:00
Paul Dicker
d56049f52a Move test_datetime_parse_from_str_with_spacesto naive::datetime 2023-09-05 14:23:14 +02:00
Paul Dicker
53b3f6bd57 Parse to NaiveDateTime in test_utc_datetime_from_str_with_spaces 2023-09-05 14:23:14 +02:00
Paul Dicker
5a6b2b40a7 Fix arbitrary string slicing in parse_rfc3339_relaxed 2023-09-05 09:16:15 +02:00
Paul Dicker
e39346e287 Move benchmarks to a separate crate 2023-09-03 07:08:09 +02:00
Paul Dicker
1b25e4717c Include doctests for code coverage 2023-09-03 07:02:57 +02:00
Paul Dicker
ecfad9e108 Fix test_time_zone_from_posix_tz in environments without a tzdb 2023-09-01 11:55:12 +02:00
Paul Dicker
0fce0d85d3 CI: run tests for wasm32-wasi target 2023-09-01 11:55:12 +02:00
Paul Dicker
417fae8afc CI: Remove cargo-hack from test_wasm 2023-09-01 11:55:12 +02:00
Paul Dicker
d92083d2ec Disable SystemTime test on wasm32-wasi 2023-09-01 11:55:12 +02:00
Paul Dicker
bbd5be5592 CI: test i686 Linux 2023-09-01 11:55:12 +02:00
Paul Dicker
a1b9d0d931 CI: merge jobs timezones_linux and timezones_other 2023-09-01 11:55:12 +02:00
Bill Fraser
f9d231b575 Correct documentation for FromStr for Weekday and Month
The parsing specifiers were wrong.
2023-08-31 22:17:05 +02:00
Paul Dicker
18f1c9057b Revert "add test_issue_866"
This reverts commit bf9f87638894dcfccb121a99653e29464be364bf.
2023-08-31 11:38:39 +02:00
Paul Dicker
243d26d994 Bump version to 0.4.28 v0.4.28 2023-08-30 21:28:33 +02:00
Paul Dicker
80946ed4e7 Fix test_type_types on 32-bit targets 2023-08-30 21:28:33 +02:00
Dirkjan Ochtman
b6a5244247 Add pitdicker as an author v0.4.27 2023-08-29 15:50:40 +02:00
Dirkjan Ochtman
b5a9850aa1 Bump version to 0.4.27 2023-08-29 15:50:40 +02:00
Paul Dicker
00d389e522 CI: Skip winapi feature in cargo hack check
(already covered by the `clock` feature)
2023-08-29 15:25:30 +02:00
Paul Dicker
30b6294ba1 Switch to windows-bindgen 2023-08-29 15:25:30 +02:00
Paul Dicker
9ab02596a7 Remove hack to accept "UTC" in timezone_offset_zulu 2023-08-29 15:15:11 +02:00
Paul Dicker
e985f08868 Switch RFC3339 formatting item to relaxed parser to match documentation 2023-08-29 15:15:11 +02:00
Paul Dicker
3f8a5005e9 Use parse_rfc3339 directly in DateTime::parse_from_rfc3339
We want this to use the strict parser directly, so we can switch the `RFC3339`
item to a relaxed parser.
2023-08-29 15:15:11 +02:00
Paul Dicker
ccd7f8545d Allow 't' as a seperator between date and time in parse_rfc3339_relaxed
From the standard:
> NOTE: Per [ABNF] and ISO8601, the "T" and "Z" characters in this syntax may
> alternatively be lower case "t" or "z" respectively.

The strict parser accepted 't', now the relaxed parser also does.
2023-08-29 15:15:11 +02:00
Paul Dicker
fb4371bcc1 Don't consume trailing whitespace in parse_rfc3339_relaxed
When used for the `RFC3339` formatting item it should not consume the trailing
whitespace, only in the `from_str` method.
2023-08-29 15:15:11 +02:00
Paul Dicker
459b82f039 Extract relaxed RFC 3339 parser from FromStr impl for DateTime
This allows us to start using the permissive parser for the `RFC3339` item,
which matches the documentation more closely.
2023-08-29 15:15:11 +02:00
Paul Dicker
1c517cf43c RFC 3339: accept space as separator between date and time
From the standard:
> NOTE: ISO 8601 defines date and time separated by "T". Applications using
> this syntax may choose, for the sake of readability, to specify a full-date
> and full-time separated by (say) a space character.

The permissive parser already accepted a space, now the strict parser also
accepts it.
The vague wording suggest more characters than 'T' and ' ' might be allowed,
but I have stopped at adding just a space.
2023-08-29 15:15:11 +02:00
Paul Dicker
39ad9b6874 Move checks for parse_from_rfc2822 to the correct test 2023-08-29 15:15:11 +02:00
Paul Dicker
c2dd740543 Fix rfc* tests with leap second
The result of `checked_add_signed` will never be a leap second, so
it is not suitable for creating test values with leap seconds.
2023-08-29 15:15:11 +02:00
Dirkjan Ochtman
2d2f84743b Use CODECOV_TOKEN when uploading coverage data 2023-08-29 13:23:13 +02:00