Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge 0.4.x #1169

Merged
merged 75 commits into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
aa8a237
fix: no panic when formatting with %#z
domodwyer Jun 8, 2023
29e728a
Add parse tests focused on timezone signage
jtmoon79 May 29, 2023
b9a0a25
Add tests for RFC 850 failures
jtmoon79 May 29, 2023
cf177ee
Replace test_tz_ascii_str with test_timezonename_new
jtmoon79 May 29, 2023
ed24478
timezone_offset_internal and TimeZoneName::new parse by chars
jtmoon79 May 29, 2023
7a4da41
timezone allows leading MINUS SIGN (U+2212)
jtmoon79 May 29, 2023
8f2e94d
Remove `#![allow(deprecated)]`
pitdicker Jun 9, 2023
67c59fd
Move test in `format::scan` to `test` module
pitdicker Jun 9, 2023
b2cb0fd
Move test in `format::parse` to `test` module
pitdicker Jun 12, 2023
fb220c8
Fix NaiveTime doc typo
zachs18 Jun 14, 2023
edbdfc1
Add test for formatting type sizes
pitdicker Jun 22, 2023
f6b453e
Add format string parsing benchmarks
pitdicker Jun 23, 2023
91b8db8
Rename `recons` to `queue`
pitdicker Jun 23, 2023
38ce591
Factor out `parse_next_item`
pitdicker Jun 23, 2023
d8ec23d
Delay parsing of localized formatting string until use
pitdicker Jun 23, 2023
13ad948
Make `StrftimeItems::new` const
pitdicker Jun 23, 2023
ea9398e
Add formatting benchmarks
pitdicker Jun 26, 2023
1a3c43a
Add FromStr for FixedOffset (#1157)
mcronce Jun 29, 2023
224933e
Remove indirection for parsing timezone offset
djc Jun 29, 2023
3330c18
Group imports from the same module
djc Jun 29, 2023
11a63a0
Inline trivial single-use function
djc Jun 29, 2023
cc6671f
Use std API for case-insensitive ASCII comparison
djc Jun 29, 2023
5293ed7
Fold zulu parsing into timezone_offset()
djc Jun 29, 2023
69456af
Fold permissive parsing into timezone_offset()
djc Jun 29, 2023
f489ee1
Move formatting to `format/format.rs`
pitdicker Jun 27, 2023
d717526
Move static formatting definitions into `parse_next_item`
pitdicker Jun 27, 2023
7afc6a2
Replace macros for formatting items with functions
pitdicker Jun 30, 2023
cc0e427
Move module declaration to top
pitdicker Jun 27, 2023
fffcf49
Merge pull request #1156 from pitdicker/refactor_format
pitdicker Jun 30, 2023
807a9fb
Only require `std` feature for `std::error::Error` impl
pitdicker Jun 30, 2023
456948a
Deduplicate test
pitdicker Jun 30, 2023
59531e0
Require `std` feature for `From<SystemTime>`
pitdicker Jun 30, 2023
e15b897
Make `test_rfc3339` work without formatting
pitdicker Jun 30, 2023
41a1b99
Make `test_rfc2822` work without formatting
pitdicker Jun 30, 2023
eec5232
Make formatting tests require `alloc` or `std` feature
pitdicker Jun 30, 2023
26bfd6c
Remove duplicate code
pitdicker Jun 30, 2023
f3e556b
Fix typo
pitdicker Jun 30, 2023
697f5d7
Require clock feature for `test_decodable_json` import
pitdicker Jun 30, 2023
72e1fba
Make formatting only available with `alloc` or `std` feature, not wit…
pitdicker Jun 30, 2023
d928890
Merge pull request #1159 from pitdicker/no_test_feature_cfg
pitdicker Jun 30, 2023
ea41eba
Remove `Tz::Offset: Display` requirement from `DateTime::to_rfc*`
pitdicker Jun 30, 2023
0d09acf
Parallelize `try_verify_against_date_command`
pitdicker Jun 30, 2023
182b50e
Merge pull request #1160 from pitdicker/formatting_without_display
pitdicker Jun 30, 2023
3dda28c
New offset formatter `OffsetFormat`
pitdicker May 20, 2023
29019fb
Test offset formatter
pitdicker Jun 30, 2023
edf413d
Rustfmt
pitdicker Jun 30, 2023
e0e4303
Merge pull request #1082 from pitdicker/offset_formatting_1
pitdicker Jun 30, 2023
55dde4a
Merge pull request #1161 from pitdicker/parallel_verify_against_date
pitdicker Jul 1, 2023
7cc0ca8
Require `clock` and `std` feature for `dateutils` tests
pitdicker Jul 1, 2023
bd23f5b
Require `clock` feature for `wasm` tests
pitdicker Jul 1, 2023
7711690
Also run integration tests with `no_std` on CI
pitdicker Jul 3, 2023
3b49eb6
test: locale's datetime and 12 hour clock time
scarf005 Mar 9, 2023
3c50b42
Update `pure-rust-locales` to 0.6
pitdicker Jul 4, 2023
dfd3cf5
Make `%r` use locale's 12 hour clock time
pitdicker Jul 3, 2023
121f5c7
Merge branch '0.4.x'
pitdicker Jul 5, 2023
ac80252
Clarify nanosecond formatting specifier doc
pitdicker Jul 5, 2023
26d03c9
const from_ymd_opt
kamadorueda Jul 5, 2023
ee3d61b
Rust issue #22255 is no longer relevant
pitdicker Jul 5, 2023
33c69f8
Split up `test_parse`
pitdicker Jul 5, 2023
838ba68
Import `Fixed` variants
pitdicker Jul 5, 2023
823e981
Backport more checks in `test_parse` from main
pitdicker Jul 5, 2023
20e7dd5
Convert macro to function
pitdicker Jul 6, 2023
677dbbe
Revert changes to `TimeZoneName::new` parser
jtmoon79 May 29, 2023
8599d7c
Add quote from man page
pitdicker Jul 3, 2023
56c6967
Test some realistic values in `test_tz_ascii_str`
pitdicker Jul 4, 2023
e5f322e
Remove `#![deny(dead_code)]`
pitdicker Jul 15, 2023
4c18df4
Remove needless `any` in feature gate
pitdicker Jul 15, 2023
c50e585
Adding automatic dependency management
DarkWanderer Dec 14, 2022
f8029b5
Update per review notes
DarkWanderer Dec 15, 2022
f4b3eba
Wrap all Dependabot ecosystem names in quotes
LingMan Feb 14, 2023
13e7924
Add branch policy explanation to PR template
djc Aug 29, 2022
c6a7515
Add various tests for current parsing
jtmoon79 Sep 8, 2022
90511c8
Backport various changes to datetime/tests.rs
pitdicker Jul 7, 2023
3993c02
Make imports similar to main branch
pitdicker Jul 7, 2023
3df0a0d
Merge branch '0.4.x'
pitdicker Jul 17, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ jobs:
# run using `bash` on all platforms for consistent
# line-continuation marks
shell: bash
- run: cargo test --lib --no-default-features
- run: cargo test --doc --no-default-features
- run: cargo test --no-default-features

no_std:
strategy:
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ __doctest = []

[dependencies]
serde = { version = "1.0.99", default-features = false, optional = true }
pure-rust-locales = { version = "0.5.2", optional = true }
pure-rust-locales = { version = "0.6", optional = true }
criterion = { version = "0.4.0", optional = true }
rkyv = { version = "0.7", optional = true }
arbitrary = { version = "1.0.0", features = ["derive"], optional = true }
Expand Down
64 changes: 64 additions & 0 deletions benches/chrono.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@

use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion};

use chrono::format::StrftimeItems;
use chrono::prelude::*;
#[cfg(feature = "unstable-locales")]
use chrono::Locale;
use chrono::{DateTime, FixedOffset, Local, Utc, __BenchYearFlags};

fn bench_datetime_parse_from_rfc2822(c: &mut Criterion) {
Expand Down Expand Up @@ -122,6 +125,57 @@ fn bench_num_days_from_ce(c: &mut Criterion) {
}
}

fn bench_parse_strftime(c: &mut Criterion) {
c.bench_function("bench_parse_strftime", |b| {
b.iter(|| {
let str = black_box("%a, %d %b %Y %H:%M:%S GMT");
let items = StrftimeItems::new(str);
black_box(items.collect::<Vec<_>>());
})
});
}

#[cfg(feature = "unstable-locales")]
fn bench_parse_strftime_localized(c: &mut Criterion) {
c.bench_function("bench_parse_strftime_localized", |b| {
b.iter(|| {
let str = black_box("%a, %d %b %Y %H:%M:%S GMT");
let items = StrftimeItems::new_with_locale(str, Locale::nl_NL);
black_box(items.collect::<Vec<_>>());
})
});
}

fn bench_format(c: &mut Criterion) {
let dt = Local::now();
c.bench_function("bench_format", |b| b.iter(|| format!("{}", dt.format("%Y-%m-%d %H-%M-%S"))));
}

fn bench_format_with_items(c: &mut Criterion) {
let dt = Local::now();
let items: Vec<_> = StrftimeItems::new("%Y-%m-%d %H-%M-%S").collect();
c.bench_function("bench_format_with_items", |b| {
b.iter(|| format!("{}", dt.format_with_items(items.iter())))
});
}

fn bench_format_manual(c: &mut Criterion) {
let dt = Local::now();
c.bench_function("bench_format_manual", |b| {
b.iter(|| {
format!(
"{}-{:02}-{:02} {:02}:{:02}:{:02}",
dt.year(),
dt.month(),
dt.day(),
dt.hour(),
dt.minute(),
dt.second()
)
})
});
}

criterion_group!(
benches,
bench_datetime_parse_from_rfc2822,
Expand All @@ -132,6 +186,16 @@ criterion_group!(
bench_year_flags_from_year,
bench_num_days_from_ce,
bench_get_local_time,
bench_parse_strftime,
bench_format,
bench_format_with_items,
bench_format_manual,
);

#[cfg(feature = "unstable-locales")]
criterion_group!(unstable_locales, bench_parse_strftime_localized,);

#[cfg(not(feature = "unstable-locales"))]
criterion_main!(benches);
#[cfg(feature = "unstable-locales")]
criterion_main!(benches, unstable_locales);
8 changes: 4 additions & 4 deletions src/date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//! ISO 8601 calendar date with time zone.
#![allow(deprecated)]

#[cfg(any(feature = "alloc", feature = "std", test))]
#[cfg(any(feature = "alloc", feature = "std"))]
use core::borrow::Borrow;
use core::cmp::Ordering;
use core::ops::{Add, AddAssign, Sub, SubAssign};
Expand All @@ -15,7 +15,7 @@ use rkyv::{Archive, Deserialize, Serialize};

#[cfg(feature = "unstable-locales")]
use crate::format::Locale;
#[cfg(any(feature = "alloc", feature = "std", test))]
#[cfg(any(feature = "alloc", feature = "std"))]
use crate::format::{DelayedFormat, Item, StrftimeItems};
use crate::naive::{IsoWeek, NaiveDate, NaiveTime};
use crate::offset::{TimeZone, Utc};
Expand Down Expand Up @@ -333,7 +333,7 @@ where
Tz::Offset: fmt::Display,
{
/// Formats the date with the specified formatting items.
#[cfg(any(feature = "alloc", feature = "std", test))]
#[cfg(any(feature = "alloc", feature = "std"))]
#[cfg_attr(docsrs, doc(cfg(any(feature = "alloc", feature = "std"))))]
#[inline]
#[must_use]
Expand All @@ -348,7 +348,7 @@ where
/// Formats the date with the specified format string.
/// See the [`crate::format::strftime`] module
/// on the supported escape sequences.
#[cfg(any(feature = "alloc", feature = "std", test))]
#[cfg(any(feature = "alloc", feature = "std"))]
#[cfg_attr(docsrs, doc(cfg(any(feature = "alloc", feature = "std"))))]
#[inline]
#[must_use]
Expand Down
Loading