pub struct MIN_LUNAR_DATE_IN_SOLAR_CALENDAR { /* private fields */ }
Expand description

最小支援的農曆日期(以西曆日期表示):1901-02-19。(lazy_static的實體)

Methods from Deref<Target = NaiveDate>§

Makes a new NaiveDateTime from the current date and given NaiveTime.

Example
use chrono::{NaiveDate, NaiveTime, NaiveDateTime};

let d = NaiveDate::from_ymd_opt(2015, 6, 3).unwrap();
let t = NaiveTime::from_hms_milli_opt(12, 34, 56, 789).unwrap();

let dt: NaiveDateTime = d.and_time(t);
assert_eq!(dt.date(), d);
assert_eq!(dt.time(), t);
👎Deprecated since 0.4.23: use and_hms_opt() instead

Makes a new NaiveDateTime from the current date, hour, minute and second.

No leap second is allowed here; use NaiveDate::and_hms_* methods with a subsecond parameter instead.

Panics on invalid hour, minute and/or second.

Makes a new NaiveDateTime from the current date, hour, minute and second.

No leap second is allowed here; use NaiveDate::and_hms_*_opt methods with a subsecond parameter instead.

Returns None on invalid hour, minute and/or second.

Example
use chrono::NaiveDate;

let d = NaiveDate::from_ymd_opt(2015, 6, 3).unwrap();
assert!(d.and_hms_opt(12, 34, 56).is_some());
assert!(d.and_hms_opt(12, 34, 60).is_none()); // use `and_hms_milli_opt` instead
assert!(d.and_hms_opt(12, 60, 56).is_none());
assert!(d.and_hms_opt(24, 34, 56).is_none());
👎Deprecated since 0.4.23: use and_hms_milli_opt() instead

Makes a new NaiveDateTime from the current date, hour, minute, second and millisecond.

The millisecond part can exceed 1,000 in order to represent the leap second.

Panics on invalid hour, minute, second and/or millisecond.

Makes a new NaiveDateTime from the current date, hour, minute, second and millisecond.

The millisecond part can exceed 1,000 in order to represent the leap second.

Returns None on invalid hour, minute, second and/or millisecond.

Example
use chrono::NaiveDate;

let d = NaiveDate::from_ymd_opt(2015, 6, 3).unwrap();
assert!(d.and_hms_milli_opt(12, 34, 56,   789).is_some());
assert!(d.and_hms_milli_opt(12, 34, 59, 1_789).is_some()); // leap second
assert!(d.and_hms_milli_opt(12, 34, 59, 2_789).is_none());
assert!(d.and_hms_milli_opt(12, 34, 60,   789).is_none());
assert!(d.and_hms_milli_opt(12, 60, 56,   789).is_none());
assert!(d.and_hms_milli_opt(24, 34, 56,   789).is_none());
👎Deprecated since 0.4.23: use and_hms_micro_opt() instead

Makes a new NaiveDateTime from the current date, hour, minute, second and microsecond.

The microsecond part can exceed 1,000,000 in order to represent the leap second.

Panics on invalid hour, minute, second and/or microsecond.

Example
use chrono::{NaiveDate, NaiveDateTime, Datelike, Timelike, Weekday};

let d = NaiveDate::from_ymd_opt(2015, 6, 3).unwrap();

let dt: NaiveDateTime = d.and_hms_micro(12, 34, 56, 789_012);
assert_eq!(dt.year(), 2015);
assert_eq!(dt.weekday(), Weekday::Wed);
assert_eq!(dt.second(), 56);
assert_eq!(dt.nanosecond(), 789_012_000);

Makes a new NaiveDateTime from the current date, hour, minute, second and microsecond.

The microsecond part can exceed 1,000,000 in order to represent the leap second.

Returns None on invalid hour, minute, second and/or microsecond.

Example
use chrono::NaiveDate;

let d = NaiveDate::from_ymd_opt(2015, 6, 3).unwrap();
assert!(d.and_hms_micro_opt(12, 34, 56,   789_012).is_some());
assert!(d.and_hms_micro_opt(12, 34, 59, 1_789_012).is_some()); // leap second
assert!(d.and_hms_micro_opt(12, 34, 59, 2_789_012).is_none());
assert!(d.and_hms_micro_opt(12, 34, 60,   789_012).is_none());
assert!(d.and_hms_micro_opt(12, 60, 56,   789_012).is_none());
assert!(d.and_hms_micro_opt(24, 34, 56,   789_012).is_none());
👎Deprecated since 0.4.23: use and_hms_nano_opt() instead

Makes a new NaiveDateTime from the current date, hour, minute, second and nanosecond.

The nanosecond part can exceed 1,000,000,000 in order to represent the leap second.

Panics on invalid hour, minute, second and/or nanosecond.

Makes a new NaiveDateTime from the current date, hour, minute, second and nanosecond.

The nanosecond part can exceed 1,000,000,000 in order to represent the leap second.

Returns None on invalid hour, minute, second and/or nanosecond.

Example
use chrono::NaiveDate;

let d = NaiveDate::from_ymd_opt(2015, 6, 3).unwrap();
assert!(d.and_hms_nano_opt(12, 34, 56,   789_012_345).is_some());
assert!(d.and_hms_nano_opt(12, 34, 59, 1_789_012_345).is_some()); // leap second
assert!(d.and_hms_nano_opt(12, 34, 59, 2_789_012_345).is_none());
assert!(d.and_hms_nano_opt(12, 34, 60,   789_012_345).is_none());
assert!(d.and_hms_nano_opt(12, 60, 56,   789_012_345).is_none());
assert!(d.and_hms_nano_opt(24, 34, 56,   789_012_345).is_none());
👎Deprecated since 0.4.23: use succ_opt() instead

Makes a new NaiveDate for the next calendar date.

Panics when self is the last representable date.

Makes a new NaiveDate for the next calendar date.

Returns None when self is the last representable date.

Example
use chrono::NaiveDate;

assert_eq!(NaiveDate::from_ymd_opt(2015, 6, 3).unwrap().succ_opt(),
           Some(NaiveDate::from_ymd_opt(2015, 6, 4).unwrap()));
assert_eq!(NaiveDate::MAX.succ_opt(), None);
👎Deprecated since 0.4.23: use pred_opt() instead

Makes a new NaiveDate for the previous calendar date.

Panics when self is the first representable date.

Makes a new NaiveDate for the previous calendar date.

Returns None when self is the first representable date.

Example
use chrono::NaiveDate;

assert_eq!(NaiveDate::from_ymd_opt(2015, 6, 3).unwrap().pred_opt(),
           Some(NaiveDate::from_ymd_opt(2015, 6, 2).unwrap()));
assert_eq!(NaiveDate::MIN.pred_opt(), None);

Returns the number of whole years from the given base until self.

Formats the date with the specified formatting items. Otherwise it is the same as the ordinary format method.

The Iterator of items should be Cloneable, since the resulting DelayedFormat value may be formatted multiple times.

Example
use chrono::NaiveDate;
use chrono::format::strftime::StrftimeItems;

let fmt = StrftimeItems::new("%Y-%m-%d");
let d = NaiveDate::from_ymd_opt(2015, 9, 5).unwrap();
assert_eq!(d.format_with_items(fmt.clone()).to_string(), "2015-09-05");
assert_eq!(d.format("%Y-%m-%d").to_string(),             "2015-09-05");

The resulting DelayedFormat can be formatted directly via the Display trait.

assert_eq!(format!("{}", d.format_with_items(fmt)), "2015-09-05");

Formats the date with the specified format string. See the format::strftime module on the supported escape sequences.

This returns a DelayedFormat, which gets converted to a string only when actual formatting happens. You may use the to_string method to get a String, or just feed it into print! and other formatting macros. (In this way it avoids the redundant memory allocation.)

A wrong format string does not issue an error immediately. Rather, converting or formatting the DelayedFormat fails. You are recommended to immediately use DelayedFormat for this reason.

Example
use chrono::NaiveDate;

let d = NaiveDate::from_ymd_opt(2015, 9, 5).unwrap();
assert_eq!(d.format("%Y-%m-%d").to_string(), "2015-09-05");
assert_eq!(d.format("%A, %-d %B, %C%y").to_string(), "Saturday, 5 September, 2015");

The resulting DelayedFormat can be formatted directly via the Display trait.

assert_eq!(format!("{}", d.format("%Y-%m-%d")), "2015-09-05");
assert_eq!(format!("{}", d.format("%A, %-d %B, %C%y")), "Saturday, 5 September, 2015");

Returns an iterator that steps by days across all representable dates.

Example

let expected = [
    NaiveDate::from_ymd_opt(2016, 2, 27).unwrap(),
    NaiveDate::from_ymd_opt(2016, 2, 28).unwrap(),
    NaiveDate::from_ymd_opt(2016, 2, 29).unwrap(),
    NaiveDate::from_ymd_opt(2016, 3, 1).unwrap(),
];

let mut count = 0;
for (idx, d) in NaiveDate::from_ymd_opt(2016, 2, 27).unwrap().iter_days().take(4).enumerate() {
   assert_eq!(d, expected[idx]);
   count += 1;
}
assert_eq!(count, 4);

for d in NaiveDate::from_ymd_opt(2016, 3, 1).unwrap().iter_days().rev().take(4) {
    count -= 1;
    assert_eq!(d, expected[count]);
}

Returns an iterator that steps by weeks across all representable dates.

Example

let expected = [
    NaiveDate::from_ymd_opt(2016, 2, 27).unwrap(),
    NaiveDate::from_ymd_opt(2016, 3, 5).unwrap(),
    NaiveDate::from_ymd_opt(2016, 3, 12).unwrap(),
    NaiveDate::from_ymd_opt(2016, 3, 19).unwrap(),
];

let mut count = 0;
for (idx, d) in NaiveDate::from_ymd_opt(2016, 2, 27).unwrap().iter_weeks().take(4).enumerate() {
   assert_eq!(d, expected[idx]);
   count += 1;
}
assert_eq!(count, 4);

for d in NaiveDate::from_ymd_opt(2016, 3, 19).unwrap().iter_weeks().rev().take(4) {
    count -= 1;
    assert_eq!(d, expected[count]);
}

Returns the NaiveWeek that the date belongs to, starting with the Weekday specified.

Trait Implementations§

The resulting type after dereferencing.
Dereferences the value.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.