Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: time-rs/time
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.3.39
Choose a base ref
...
head repository: time-rs/time
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.3.40
Choose a head ref
  • 9 commits
  • 45 files changed
  • 1 contributor

Commits on Mar 10, 2025

  1. Verified

    This commit was signed with the committer’s verified signature.
    jhpratt Jacob Pratt
    Copy the full SHA
    e3dcbd3 View commit details
  2. Permit visibility in serde::format_description!

    jhpratt committed Mar 10, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    jhpratt Jacob Pratt
    Copy the full SHA
    b2b602a View commit details

Commits on Mar 11, 2025

  1. Fix UI tests, build on MSRV

    jhpratt committed Mar 11, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    jhpratt Jacob Pratt
    Copy the full SHA
    ad945a9 View commit details

Commits on Mar 13, 2025

  1. Update to deranged 0.4

    jhpratt committed Mar 13, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    jhpratt Jacob Pratt
    Copy the full SHA
    1bc4ce0 View commit details

Commits on Mar 15, 2025

  1. Remove region markers

    While neat, they're rarely used in practice.
    jhpratt committed Mar 15, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    jhpratt Jacob Pratt
    Copy the full SHA
    56187f1 View commit details
  2. Move interop between datetime types to single mod

    jhpratt committed Mar 15, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    jhpratt Jacob Pratt
    Copy the full SHA
    79a4b62 View commit details
  3. Verified

    This commit was signed with the committer’s verified signature.
    jhpratt Jacob Pratt
    Copy the full SHA
    84f3a75 View commit details

Commits on Mar 18, 2025

  1. Verified

    This commit was signed with the committer’s verified signature.
    jhpratt Jacob Pratt
    Copy the full SHA
    c386cac View commit details
  2. v0.3.40 release

    jhpratt committed Mar 18, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    jhpratt Jacob Pratt
    Copy the full SHA
    6de297b View commit details
Showing with 587 additions and 642 deletions.
  1. +6 −0 CHANGELOG.md
  2. +48 −11 Cargo.lock
  3. +3 −3 Cargo.toml
  4. +0 −8 benchmarks/date.rs
  5. +0 −14 benchmarks/duration.rs
  6. +0 −4 benchmarks/instant.rs
  7. +0 −10 benchmarks/offset_date_time.rs
  8. +0 −4 benchmarks/primitive_date_time.rs
  9. +0 −6 benchmarks/time.rs
  10. +0 −6 benchmarks/utc_offset.rs
  11. +0 −2 tests/parse_format_description.rs
  12. +21 −15 tests/serde/macros.rs
  13. +1 −1 time-core/Cargo.toml
  14. +26 −0 time-core/src/hint.rs
  15. +1 −0 time-core/src/lib.rs
  16. +25 −0 time-core/src/util.rs
  17. +1 −1 time-macros/Cargo.toml
  18. +65 −37 time-macros/src/lib.rs
  19. +7 −3 time-macros/src/serde_format_description.rs
  20. +1 −1 time/Cargo.toml
  21. +0 −16 time/src/date.rs
  22. +38 −16 time/src/duration.rs
  23. +0 −6 time/src/format_description/modifier.rs
  24. +0 −6 time/src/format_description/owned_format_item.rs
  25. +0 −4 time/src/formatting/formattable.rs
  26. +0 −6 time/src/formatting/mod.rs
  27. +0 −6 time/src/instant.rs
  28. +20 −11 time/src/internal_macros.rs
  29. +27 −0 time/src/interop/js_sys_date_offsetdatetime.rs
  30. +26 −0 time/src/interop/js_sys_date_utcdatetime.rs
  31. +28 −0 time/src/interop/mod.rs
  32. +75 −0 time/src/interop/offsetdatetime_systemtime.rs
  33. +68 −0 time/src/interop/offsetdatetime_utcdatetime.rs
  34. +75 −0 time/src/interop/utcdatetime_systemtime.rs
  35. +10 −0 time/src/lib.rs
  36. +2 −11 time/src/month.rs
  37. +1 −163 time/src/offset_date_time.rs
  38. +0 −6 time/src/parsing/component.rs
  39. +0 −4 time/src/parsing/parsable.rs
  40. +0 −18 time/src/primitive_date_time.rs
  41. +3 −19 time/src/serde/mod.rs
  42. +0 −12 time/src/time.rs
  43. +7 −200 time/src/utc_date_time.rs
  44. +0 −10 time/src/utc_offset.rs
  45. +2 −2 time/src/util.rs
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -6,6 +6,12 @@ The format is based on [Keep a Changelog]. This project adheres to [Semantic Ver

---

## 0.3.40 [2025-03-18]

### Added

- Visibility modifiers may now be added to the `mod` generated by `time::sere::format_description!`.

## 0.3.39 [2025-03-06]

### Fixed
59 changes: 48 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -4,11 +4,11 @@ members = ["time", "time-core", "time-macros"]
resolver = "2"

[workspace.dependencies]
time-core = { path = "time-core", version = "=0.1.3" }
time-macros = { path = "time-macros", version = "=0.2.20" }
time-core = { path = "time-core", version = "=0.1.4" }
time-macros = { path = "time-macros", version = "=0.2.21" }

criterion = { version = "0.5.1", default-features = false }
deranged = { version = "0.3.9", default-features = false, features = [
deranged = { version = "0.4.0", default-features = false, features = [
"powerfmt",
] }
itoa = "1.0.1"
8 changes: 0 additions & 8 deletions benchmarks/date.rs
Original file line number Diff line number Diff line change
@@ -35,7 +35,6 @@ const DATES: [Date; 24] = [
setup_benchmark! {
"Date",

// region: constructors
fn from_calendar_date(ben: &mut Bencher<'_>) {
ben.iter(|| Date::from_calendar_date(2019, Month::January, 1));
ben.iter(|| Date::from_calendar_date(2019, Month::December, 31));
@@ -66,9 +65,7 @@ setup_benchmark! {
}
});
}
// endregion constructors

// region: getters
fn year(ben: &mut Bencher<'_>) {
let d = date!(2019-002);
ben.iter(|| d.year());
@@ -177,9 +174,7 @@ setup_benchmark! {
}
});
}
// endregion getters

// region: attach time
fn midnight(ben: &mut Bencher<'_>) {
ben.iter(|| date!(1970-01-01).midnight());
}
@@ -203,9 +198,7 @@ setup_benchmark! {
fn with_hms_nano(ben: &mut Bencher<'_>) {
ben.iter(|| date!(1970-01-01).with_hms_nano(0, 0, 0, 0));
}
// endregion attach time

// region: trait impls
fn add(ben: &mut Bencher<'_>) {
let dt = 5.days();
ben.iter(|| date!(2019-01-01) + dt);
@@ -281,5 +274,4 @@ setup_benchmark! {
ben.iter(|| first.cmp(&second));
ben.iter(|| second.cmp(&first));
}
// endregion trait impls
}
14 changes: 0 additions & 14 deletions benchmarks/duration.rs
Original file line number Diff line number Diff line change
@@ -7,7 +7,6 @@ use time::Duration;
setup_benchmark! {
"Duration",

// region: is_{sign}
fn is_zero(ben: &mut Bencher<'_>) {
let a = (-1).nanoseconds();
let b = 0.seconds();
@@ -34,9 +33,7 @@ setup_benchmark! {
ben.iter(|| b.is_positive());
ben.iter(|| c.is_positive());
}
// endregion is_{sign}

// region: abs
fn abs(ben: &mut Bencher<'_>) {
let a = 1.seconds();
let b = 0.seconds();
@@ -54,9 +51,7 @@ setup_benchmark! {
ben.iter(|| b.unsigned_abs());
ben.iter(|| c.unsigned_abs());
}
// endregion abs

// region: constructors
fn new(ben: &mut Bencher<'_>) {
ben.iter(|| Duration::new(1, 0));
ben.iter(|| Duration::new(-1, 0));
@@ -172,9 +167,7 @@ setup_benchmark! {
ben.iter(|| c.whole_weeks());
ben.iter(|| d.whole_weeks());
}
// endregion constructors

// region: getters
fn whole_days(ben: &mut Bencher<'_>) {
let a = Duration::days(1);
let b = Duration::days(-1);
@@ -302,9 +295,7 @@ setup_benchmark! {
ben.iter(|| a.subsec_nanoseconds());
ben.iter(|| b.subsec_nanoseconds());
}
// endregion getters

// region: checked arithmetic
fn checked_add(ben: &mut Bencher<'_>) {
let a = 5.seconds();
let b = Duration::MAX;
@@ -345,9 +336,7 @@ setup_benchmark! {
ben.iter(|| a.checked_div(2));
ben.iter(|| a.checked_div(0));
}
// endregion checked arithmetic

// region: saturating arithmetic
fn saturating_add(ben: &mut Bencher<'_>) {
let a = 5.seconds();
let b = Duration::MAX;
@@ -399,9 +388,7 @@ setup_benchmark! {
ben.iter(|| f.saturating_mul(-2));
ben.iter(|| g.saturating_mul(-2));
}
// endregion saturating arithmetic

// region: trait impls
fn try_from_std_duration(ben: &mut Bencher<'_>) {
let a = 0.std_seconds();
let b = 1.std_seconds();
@@ -724,5 +711,4 @@ setup_benchmark! {
ben.iter(|| d > a);
ben.iter(|| e < c);
}
// endregion trait impls
}
4 changes: 0 additions & 4 deletions benchmarks/instant.rs
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@ use time::{Duration, Instant};
setup_benchmark! {
"Instant",

// region: checked arithmetic
fn checked_add(ben: &mut Bencher<'_>) {
let instant = Instant::now();
let dt = 5.seconds();
@@ -21,9 +20,7 @@ setup_benchmark! {
let dt = 5.seconds();
ben.iter(|| instant.checked_sub(dt));
}
// endregion checked arithmetic

// region: trait impls
fn sub(ben: &mut Bencher<'_>) {
let start: Instant = Instant::now();
let end: Instant = start + 1.milliseconds();
@@ -89,5 +86,4 @@ setup_benchmark! {
[|instant| *instant -= dt]
);
}
// endregion trait impls
}
10 changes: 0 additions & 10 deletions benchmarks/offset_date_time.rs
Original file line number Diff line number Diff line change
@@ -8,22 +8,19 @@ use time::OffsetDateTime;
setup_benchmark! {
"OffsetDateTime",

// region: now
fn now_utc(ben: &mut Bencher<'_>) {
ben.iter(OffsetDateTime::now_utc);
}

fn now_local(ben: &mut Bencher<'_>) {
ben.iter(OffsetDateTime::now_local);
}
// endregion now

fn to_offset(ben: &mut Bencher<'_>) {
ben.iter(|| datetime!(2000-01-01 0:00 +11).to_offset(offset!(-5)));
ben.iter(|| datetime!(2000-01-01 0:00 +11).to_offset(offset!(-8)));
}

// region: constructors
fn from_unix_timestamp(ben: &mut Bencher<'_>) {
ben.iter(|| OffsetDateTime::from_unix_timestamp(0));
ben.iter(|| OffsetDateTime::from_unix_timestamp(1_546_300_800));
@@ -33,9 +30,7 @@ setup_benchmark! {
ben.iter(|| OffsetDateTime::from_unix_timestamp_nanos(0));
ben.iter(|| OffsetDateTime::from_unix_timestamp_nanos(1_546_300_800_000_000_000));
}
// endregion constructors

// region: getters
fn offset(ben: &mut Bencher<'_>) {
ben.iter(|| datetime!(2019-01-01 0:00 UTC).offset());
ben.iter(|| datetime!(2019-01-01 0:00 +1).offset());
@@ -88,9 +83,7 @@ setup_benchmark! {
ben.iter(|| datetime!(2019-01-01 0:00 UTC).second());
ben.iter(|| datetime!(2018-12-31 23:00 -1).second());
}
// endregion getters

// region: replacement
fn replace_time(ben: &mut Bencher<'_>) {
ben.iter(|| datetime!(2020-01-01 5:00 UTC).replace_time(time!(12:00)));
ben.iter(|| datetime!(2020-01-01 12:00 -5).replace_time(time!(7:00)));
@@ -110,9 +103,7 @@ setup_benchmark! {
fn replace_offset(ben: &mut Bencher<'_>) {
ben.iter(|| datetime!(2020-01-01 0:00 UTC).replace_offset(offset!(-5)));
}
// endregion replacement

// region: trait impls
fn partial_eq(ben: &mut Bencher<'_>) {
ben.iter(|| datetime!(1999-12-31 23:00 -1) == datetime!(2000-01-01 0:00 UTC));
}
@@ -425,5 +416,4 @@ setup_benchmark! {
ben.iter(|| SystemTime::from(b));
ben.iter(|| SystemTime::from(c));
}
// endregion trait impls
}
4 changes: 0 additions & 4 deletions benchmarks/primitive_date_time.rs
Original file line number Diff line number Diff line change
@@ -8,7 +8,6 @@ setup_benchmark! {
// All getters are trivially dispatched to the relevant field, and do not need to be benchmarked
// a second time.

// region: attach offset
fn assume_offset(ben: &mut Bencher<'_>) {
ben.iter(|| datetime!(2019-01-01 0:00).assume_offset(offset!(UTC)));
ben.iter(|| datetime!(2019-01-01 0:00).assume_offset(offset!(-1)));
@@ -17,9 +16,7 @@ setup_benchmark! {
fn assume_utc(ben: &mut Bencher<'_>) {
ben.iter(|| datetime!(2019-01-01 0:00).assume_utc());
}
// endregion attach offset

// region: trait impls
fn add_duration(ben: &mut Bencher<'_>) {
let a = 5.days();
let b = 1.days();
@@ -144,5 +141,4 @@ setup_benchmark! {
ben.iter(|| datetime!(2019-01-01 0:00:01).partial_cmp(&datetime!(2019-01-01 0:00)));
ben.iter(|| datetime!(2019-01-01 0:00:00.000_000_001).partial_cmp(&datetime!(2019-01-01 0:00)));
}
// endregion trait impls
}
Loading