TimeUnit#
The unit in which a duration or lag value is counted. It's the type of SchedulingConfig::duration_unit (default TimeUnit::Day), TaskData::duration_unit, and the lag_unit field of LinkData, LinkAdd and LinkUpdate. Convert a string with TimeUnit::parse.
Declaration#
With the serde feature, TimeUnit implements Serialize and Deserialize, using the lowercase names "minute", "hour" and "day".
Variants#
| Variant | Description |
|---|---|
Minute |
Values are counted in minutes. |
Hour |
Values are counted in hours. |
Day |
Values are counted in days. |
The week, month and year units are reserved and not supported yet.
Associated functions#
parse#
Converts a lowercase unit name to a TimeUnit.
Parameters
| Name | Type | Description |
|---|---|---|
s |
&str |
"minute", "hour" or "day". Matching is case-sensitive. |
Returns - the matching variant.
Errors - Err(String) with a message when s is "week", "month" or "year" (reserved, not supported yet) or any other unknown name.
Methods#
as_str#
Returns the lowercase name of the unit: "minute", "hour" or "day". TimeUnit::parse accepts this name back.
Example#
use ;
Related#
SchedulingConfig- sets the project-wide unitTaskData- overrides the unit for one taskBasis- the load bucket derived from a unit- Project data - choosing a duration unit for a snapshot
- Working time and calendars - how durations in each unit map onto working time