DateTime#
A naive local date-time at minute precision, with no timezone and no DST. Every date the API accepts or returns is a DateTime, for example the dates in TaskData and SchedulingConfig. Build one with DateTime::from_ymd_hm or convert it from a chrono::NaiveDateTime.
Declaration#
;
The inner value is private. DateTime doesn't implement Default or FromStr. With the serde feature it also implements Serialize and Deserialize; see Serialization.
Values compare by time: an earlier date-time is less than a later one.
Associated functions#
from_ymd_hm#
Builds a date-time from calendar fields.
Parameters
| Name | Type | Description |
|---|---|---|
y |
i32 |
Year. |
m |
u32 |
Month, 1..=12. |
d |
u32 |
Day of the month, checked against the month and leap years. |
h |
u32 |
Hour, 0..=23. |
min |
u32 |
Minute, 0..=59. |
Returns - Some(DateTime), or None when the fields don't form a valid date and time (for example February 30 or hour 24).
Methods#
minutes#
Minutes since 1970-01-01 00:00, counted as naive time. Dates before 1970 give negative values. The difference of two minutes() values is the elapsed wall-clock time between them; no working calendar is applied.
Returns - the minute count.
Conversions#
From<chrono::NaiveDateTime>#
Truncates seconds and sub-seconds: 2026-03-02 08:15:59 becomes 2026-03-02 08:15. plen-core doesn't re-export chrono, so add it to your own dependencies (cargo add chrono) to use this conversion.
From<DateTime> for chrono::NaiveDateTime#
Returns the same date and time with seconds set to 0.
Display#
Display writes YYYY-MM-DD HH:MM, for example 2026-03-02 08:00.
Serialization#
Requires the serde feature:
Serializewrites theDisplaystring,"YYYY-MM-DD HH:MM".Deserializereads a string, trims surrounding whitespace and acceptsYYYY-MM-DD HH:MM,YYYY-MM-DD HH:MM:SS, the same two forms withTinstead of the space, and a bare dateYYYY-MM-DD(read as00:00). Seconds are truncated. Any other string fails with the error messageinvalid date.
Example#
use DateTime;
Related#
TaskData- task dates and constraint dates areDateTimevaluesSchedulingConfig- project start and end areDateTimevaluesMutation- returns computed task dates asDateTime- Quick start - builds dates with
from_ymd_hmin a first schedule - Project data - how dates are read in an input snapshot