TimeUnit#
The unit that a task's duration and a link's lag are counted in. The project default is SchedulingConfig.DurationUnit. A task overrides it with TaskData.DurationUnit, and a link with LinkData.LagUnit.
Declaration#
namespace Plen;
public enum TimeUnit { Minute, Hour, Day }
default(TimeUnit) is Minute. The default of SchedulingConfig.DurationUnit is Day.
Values#
| Value | Description |
|---|---|
Minute |
Working minutes. Amounts are rounded to whole minutes when a date is placed. |
Hour |
Working hours of 60 minutes. Amounts are rounded to whole minutes when a date is placed. |
Day |
Working days. A working date of any length counts as one day, and a placed date keeps its time of day. Amounts are rounded to whole days when a date is placed. |
Weeks, months and years have no value.
A duration or lag in these units is working time: non-working time on the task's calendar doesn't count. TaskData.LevelingDelay and Pause lengths use the same unit as elapsed time, where Day means 24 hours.
Where it's used#
| Member | Type | Meaning |
|---|---|---|
SchedulingConfig.DurationUnit |
TimeUnit |
Project default, Day unless set. |
TaskData.DurationUnit |
TimeUnit? |
Unit of the task's Duration, LevelingDelay and Pauses. null uses the project default. |
LinkData.LagUnit |
TimeUnit? |
Unit of the link's Lag. null uses the project default. |
LinkAdd.LagUnit |
TimeUnit? |
Same as LinkData.LagUnit, for a link added after the first solve. |
LinkUpdate.LagUnit |
Patch<TimeUnit> |
Changes the unit of an existing link's lag. |
TimeUnit has no parse or spelling helpers. In JSON the values are spelled "minute", "hour" and "day"; the Plen.Wire package reads and writes them. See Exchange JSON with a client.
Example#
The project counts in days, one task counts in hours, and one link's lag is in minutes:
using Plen;
var start = Moment.FromYmdHm(2026, 4, 6, 8, 0)
?? throw new InvalidOperationException("invalid date");
var data = new ProjectData
{
Config = new SchedulingConfig { DurationUnit = TimeUnit.Day },
Tasks =
[
new TaskData(1) { StartDate = start, Duration = 2.0 },
new TaskData(2) { StartDate = start, Duration = 6.0, DurationUnit = TimeUnit.Hour },
],
Links =
[
new LinkData { Id = "a", Source = 1, Target = 2, Lag = 30.0, LagUnit = TimeUnit.Minute },
],
};
var result = Engine.Schedule(data, new SolveOptions());
foreach (var update in result.Updates)
{
Console.WriteLine(update);
}
Related#
SchedulingConfig- the project default unitTaskData- per-task duration unitLinkData- per-link lag unit- Project data - durations and units