C
C#2y ago
SWEETPONY

✅ How to break date into intervals?

I have this:
/// <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
};
}
}
For example, we have following:
"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
}
]
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
1 Reply
SWEETPONY
SWEETPONYOP2y ago
9 + 9 = 18 and it's the end of the day /close
Want results from more Discord servers?
Add your server