You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Ical.Net/CalendarComponents/Todo.cs
+51Lines changed: 51 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -3,6 +3,7 @@
3
3
// Licensed under the MIT license.
4
4
//
5
5
6
+
usingSystem;
6
7
usingSystem.Collections.Generic;
7
8
usingSystem.Diagnostics;
8
9
usingSystem.Linq;
@@ -63,6 +64,56 @@ public virtual Duration? Duration
63
64
}
64
65
}
65
66
67
+
/// <summary>
68
+
/// Gets the duration that gets added to the period start time to get the period end time.
69
+
/// <para/>
70
+
/// If the <see cref="Duration"/> property is not null, its value will be returned.<br/>
71
+
/// If <see cref="RecurringComponent.DtStart"/> and <see cref="Due"/> are set, it will return <see cref="Due"/> minus <see cref="RecurringComponent.DtStart"/>.<br/>
72
+
/// </summary>
73
+
/// <remarks>
74
+
/// Note: For recurring events, the <b>exact duration</b> of individual occurrences may vary due to DST transitions
75
+
/// of the given <see cref="RecurringComponent.DtStart"/> and <see cref="Due"/> timezones.
76
+
/// </remarks>
77
+
/// <returns>The duration that gets added to the period start time to get the period end time.</returns>
78
+
publicDuration?EffectiveDuration
79
+
{
80
+
get
81
+
{
82
+
// 3.8.5.3. Recurrence Rule
83
+
// If the duration of the recurring component is specified with the
84
+
// "DURATION" property, then the same NOMINAL duration will apply to
85
+
// all the members of the generated recurrence set and the exact
86
+
// duration of each recurrence instance will depend on its specific
87
+
// start time.
88
+
if(Durationis not null)
89
+
returnDuration.Value;
90
+
91
+
if(DtStartis not {}dtStart)
92
+
{
93
+
// Mustn't happen
94
+
thrownewInvalidOperationException("DtStart must be set.");
95
+
}
96
+
97
+
if(Dueis{}dtEnd)
98
+
{
99
+
/*
100
+
3.8.5.3. Recurrence Rule:
101
+
If the duration of the recurring component is specified with the
102
+
"DTEND" or "DUE" property, then the same EXACT duration will apply
103
+
to all the members of the generated recurrence set.
104
+
105
+
We use the difference from DtStart to DtEnd (neglecting timezone),
106
+
because the caller will set the period end time to the
107
+
same timezone as the event end time. This finally leads to an exact duration
108
+
calculation from the zoned start time to the zoned end time.
0 commit comments