1450 Commits

Author SHA1 Message Date
Paul Dicker
b92b736f52 Set main branch as dependabot target 2024-02-02 14:10:19 +01:00
Paul Dicker
6f06e1ab0e Make methods on DateTime const where possible 2024-02-02 09:51:57 +01:00
Paul Dicker
fd66791996 Make remaining methods on NaiveDateTime const 2024-02-01 21:29:28 +01:00
Paul Dicker
f78eb20ef1 Make NaiveTime::overflowing_sub_signed const 2024-02-01 21:29:28 +01:00
Paul Dicker
e56f9c5797 Simplify NaiveTime::overflowing_add_signed and make const 2024-02-01 21:29:28 +01:00
Paul Dicker
4836953431 Make NaiveTime::signed_duration_since const 2024-02-01 21:29:28 +01:00
Paul Dicker
912cc63602 Make remaining methods on NaiveDate const 2024-02-01 21:29:28 +01:00
Paul Dicker
45785b58d3 Make methods on NaiveWeek const 2024-02-01 21:29:28 +01:00
Paul Dicker
7cc4ce89ea Make DateTime<Utc>::from_timestamp const 2024-02-01 21:29:28 +01:00
Scott Driggers
d7afd72da5 Add test_duration_const() 2024-02-01 21:29:28 +01:00
Paul Dicker
7c4bf0b578 Make all methods on Duration const 2024-02-01 21:29:28 +01:00
Paul Dicker
a14b16071f Add Duration::new 2024-02-01 21:29:28 +01:00
Paul Dicker
086a26b020 Remove duplicate try_opt macro 2024-02-01 21:29:28 +01:00
Dan Williams
e031ffbad5 Improved Duration documentation
- Added a description of internal storage and permissable range to the
    Duration type.

  - Adjusted formatting of `Duration` in a number of related function
    Rustdoc blocks, to aid readability.

  - Clarified comments for Duration::num_milliseconds().
2024-02-01 20:56:49 +01:00
Dan Williams
ec831e7bc9 Added Duration::try_milliseconds()
- Added a new Duration::try_milliseconds() function, to attempt to
    create a new milliseconds-based Duration, and return None if it
    fails, based on checking against MAX and MIN. Currently, failure can
    only happen for exactly one value, which is i64::MIN.

  - Updated Duration::milliseconds() to call try_milliseconds() and
    panic if None is returned. Although panicking in production code and
    especially library code is bad, this is in keeping with current
    Chrono behaviour. Note that this function is now no longer const.

  - Updated the Duration::milliseconds() documentation to make it clear
    that it now panics.

  - Added documentation to Duration::microseconds() and nanoseconds() to
    make it clear that they are infallible.

  - All tests now pass, including the one previously ignored.
2024-02-01 20:56:49 +01:00
Dan Williams
e5309f8aa7 Improved the documentation of Duration constructors
- Added Panics and Errors sections where appropriate, as these are
    generally-expected and help draw attention to the fact that the
    standard (i.e. non-try) constructors can panic. The Errors section
    for the try constructors is common practice when returning None for
    overflow situations as well as for functions actually returning a
    Result.

  - Added an further explanation of the behaviour of the seconds()
    constructor.

  - Minor additional readability edits.
2024-02-01 20:56:49 +01:00
Dan Williams
d87df5de78 Added additional tests for Duration bounds
- Added tests for creating the maximum and minimum allowable values of
    Durations having a magnitude of seconds, testing the limits plus one
    value beyond the limits in both directions. These tests all pass.

  - Expanded the tests for creating the maximum and minimum allowable
    values of Durations having a magnitude of milliseconds. These tests
    examine the results in more detail, document what is being tested,
    and also test one value beyond the limits in both directions.
    Notably, the test for Duration::milliseconds() construction for
    i64::MIN currently fails, as it is erroneously allowed. This test is
    ignored for now, until the fix is applied.

  - Expanded the tests for creating the maximum and minimum allowable
    values of Durations having a magnitude of microseconds and
    nanoseconds. These tests examine the results in more detail,
    document what is being tested, and also test one value beyond the
    limits in both directions. They also test the maximum reportable
    value from .num_*() and the maximum storable value of the Duration
    separately.

  - Separated out the tests for MAX and MIN, for clarity.

  - Added additional tests for addition and subtraction operations on
    Durations, ensuring that equivalent tests are performed against both
    operations, such as adding and subtracting zero, adding and
    subtracting one nanosecond, and others.

  - Added tests for greater-than and less-than comparison of two
    Durations, to ensure that internal representation of partial seconds
    is correctly ordered.
2024-02-01 20:56:49 +01:00
Paul Dicker
83d5aae6aa Remove stray documentation 2024-02-01 17:37:09 +01:00
Paul Dicker
cf17f7a239 Remove deprecated methods from documentation 2024-01-30 20:47:54 +01:00
Paul Dicker
3e6fa4c0df Don't use deprecated method in wasm test 2024-01-30 20:47:54 +01:00
Paul Dicker
02a96eba57 Remove workaround for Rust < 1.61 2024-01-29 09:31:44 +01:00
Paul Dicker
baa55d0847 CI: test arbitrary feature 2024-01-26 15:55:32 +01:00
Paul Dicker
f3e56c505d Arbitrary does not (yet) support no_std 2024-01-26 15:55:32 +01:00
Paul Dicker
76822ae051 Don't use deprecated method in impl Arbitrary for DateTime 2024-01-26 15:55:32 +01:00
Paul Dicker
ec557d2843 Specify branch for GitHub Actions badge and fix link 2024-01-26 15:15:50 +01:00
Dirkjan Ochtman
5cbb9a7d9c Update branch names in pull request template 2024-01-26 14:53:31 +01:00
Eden Mikitas
94f9738b03 Fix the formatting of timestamp_micros's Example doc 2024-01-26 10:42:48 +01:00
Paul Dicker
7c419a358e Prepare 0.4.33 release v0.4.33 2024-01-25 13:32:46 +01:00
Paul Dicker
a9b37c4c81 Make rkyv feature default to size_32 2024-01-25 13:32:46 +01:00
Paul Dicker
a73b54320a Don't assume rkyv-(16|32|64) implies the rkyv feature 2024-01-25 13:32:46 +01:00
Dan Williams
b5381f8fb5 Fixed typo in Duration::hours() exception 2024-01-25 09:48:03 +01:00
Kenny Kerr
bf704191f2 52 v0.4.32 2024-01-22 23:04:19 +01:00
Dirkjan Ochtman
7757386368 Prepare 0.4.32 release 2024-01-22 22:21:52 +01:00
Tam Pham
cee242a656 Fix typos in Datelike impl for DateTime 2024-01-18 19:07:06 +01:00
Makro
6ec8f97d16
Add from_timestamp_millis to DateTime<Utc> (#1374)
Co-authored-by: xmakro <makro@>
2024-01-09 17:50:58 +01:00
gibbz00
65f0cc2aa4 CI Linting: Fix missing sources checkout in toml job. 2024-01-09 17:47:35 +01:00
Dan Williams
5536687c0d
Add Months::as_u32() (#1373) 2024-01-09 13:24:41 +01:00
Thayne McCombs
6033afea6f docs: Improve deprecation of TimeZone::datetime_from_str
Add recommending using `NaiveDate::parse_from_str` as well
2024-01-04 15:49:11 +01:00
Gerd Zellweger
849932b09b Change the CI --all-features to an explicit list.
This is due to the mutually exclusive features in rkyv which
we expose now. `--all-features` will now activate them and the crate
will fail to compile rkyv. We work around this by defining
an explicit list of all mutually exclusive features to.

Unfortunately there isn't an easy way to share env variables
among different YAML files
(https://github.com/actions/runner/issues/655).

There also isn't a good way to specify `--all-features` minus
"just a few" (https://github.com/rust-lang/cargo/issues/3126)
aside from giving the complete list.

Signed-off-by: Gerd Zellweger <mail@gerdzellweger.com>
2023-12-29 09:51:40 +01:00
Gerd Zellweger
3f22822086 Expose rkyv features as features for chrono users.
rkyv by default serializes usize as u32. This isn't ideal
on most modern platforms and unfortunately is configured through
a feature flag.

If we just set `default-features = false` in the rkyv Cargo
dependency, the crate fails to compile because all the size features
are mutually exclusive. On the other hand if we want to
e.g., change the serialization of usize to 64-bit and
we also want to use chrono this currently fails to compile
because chrono always enables rkyv/size_32.

This re-exports the relevant rkyv features so users can
choose which serialization to enable. The approach
is similar to what the ordered-float crate does:

8111b34537/Cargo.toml (L37)

Signed-off-by: Gerd Zellweger <mail@gerdzellweger.com>
2023-12-29 09:51:40 +01:00
Dirkjan Ochtman
d7b4a82027 Silence clippy lint for test code 2023-11-27 13:05:40 +01:00
Ali Mirghasemi
e1a9494e24
Add from_timestamp_nanos (#1357)
* Add from_timestamp_nanos

Add and implement from_timestamp_nanos and add unit test for it

* Fix lint check error

* Add pub(crate) for NANOS_PER_SEC

* Replace number with constant variable
2023-11-24 09:38:25 +01:00
dcechano
6f3ab9dd5a Add From<NaiveDate> for NaiveDateTime 2023-11-20 11:52:05 +01:00
dependabot[bot]
039189c4a1 Update windows-targets requirement from 0.48 to 0.52
Updates the requirements on [windows-targets](https://github.com/microsoft/windows-rs) to permit the latest version.
- [Release notes](https://github.com/microsoft/windows-rs/releases)
- [Commits](https://github.com/microsoft/windows-rs/compare/windows-targets-0.48.1...0.52.0)

---
updated-dependencies:
- dependency-name: windows-targets
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-20 09:34:35 +01:00
Matt Mastracci
c0f418bbbf Split clock feature into clock and now 2023-11-08 15:48:17 +01:00
Dirkjan Ochtman
dd3f2f81c4 Bump MSRV to 1.61 2023-11-07 11:17:45 +01:00
jtmoon79
fbd67ab02c test.yml remove errant with: node-version 2023-11-06 09:27:29 +01:00
dependabot[bot]
15c8885365 Bump actions/setup-node from 3 to 4
Bumps [actions/setup-node](https://github.com/actions/setup-node) from 3 to 4.
- [Release notes](https://github.com/actions/setup-node/releases)
- [Commits](https://github.com/actions/setup-node/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/setup-node
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-01 17:40:46 +01:00
Mikhail Katychev
02bdd1ddc8
archive derive of PartialEq for rkyv - 0.4.x (#959) 2023-10-10 16:25:06 +02:00
Paul Dicker
0f19d6be1d Adjust Duration::MIN by 1 millisecond 2023-09-29 13:42:20 +02:00