✅ How to break date into intervals?
I have this:
For example, we have following:
so I would like to break in into this intervals:
09:00:00 - 12:00:00,
12:00:00 - 13:00:00
13:00:00 - / 18:00:00
/// <summary>
/// List of intervals inside worktime
/// </summary>
[JsonProperty( PropertyName = "schedule_intervals" )]
public List<WorktimeScheduleInterval> ScheduleIntervals { get; set; }
public class WorktimeScheduleInterval
{
/// <summary>
/// Shift of the interval relative to 00:00 of the first day of the cycle
/// </summary>
[JsonProperty( PropertyName = "time_shift" )]
[JsonRequired]
public TimeSpan TimeShift { get; set; }
/// <summary>
/// Duration of interval
/// </summary>
[JsonProperty( PropertyName = "duration" )]
[JsonRequired]
public TimeSpan Duration { get; set; }
/// <summary>
/// Interval type
/// </summary>
[JsonProperty( PropertyName = "interval_type" )]
[JsonRequired]
public ShiftIntervalType IntervalType { get; set; }
public WorktimeScheduleInterval Clone( TimeSpan shift )
{
return new WorktimeScheduleInterval()
{
TimeShift = TimeShift + shift,
Duration = Duration,
IntervalType = IntervalType
};
}
}
/// <summary>
/// List of intervals inside worktime
/// </summary>
[JsonProperty( PropertyName = "schedule_intervals" )]
public List<WorktimeScheduleInterval> ScheduleIntervals { get; set; }
public class WorktimeScheduleInterval
{
/// <summary>
/// Shift of the interval relative to 00:00 of the first day of the cycle
/// </summary>
[JsonProperty( PropertyName = "time_shift" )]
[JsonRequired]
public TimeSpan TimeShift { get; set; }
/// <summary>
/// Duration of interval
/// </summary>
[JsonProperty( PropertyName = "duration" )]
[JsonRequired]
public TimeSpan Duration { get; set; }
/// <summary>
/// Interval type
/// </summary>
[JsonProperty( PropertyName = "interval_type" )]
[JsonRequired]
public ShiftIntervalType IntervalType { get; set; }
public WorktimeScheduleInterval Clone( TimeSpan shift )
{
return new WorktimeScheduleInterval()
{
TimeShift = TimeShift + shift,
Duration = Duration,
IntervalType = IntervalType
};
}
}
"schedule_intervals": [
{
"duration": "09:00:00",
"time_shift": "09:00:00",
"interval_type": 1
},
{
"duration": "01:00:00",
"time_shift": "12:00:00",
"interval_type": 4
}
]
"schedule_intervals": [
{
"duration": "09:00:00",
"time_shift": "09:00:00",
"interval_type": 1
},
{
"duration": "01:00:00",
"time_shift": "12:00:00",
"interval_type": 4
}
]
1 Reply
9 + 9 = 18 and it's the end of the day
/close