Skip to content

Commit a2ec4fa

Browse files
committed
Remove GetOccurrences.GetOccurrencesOfDay() and related.
1 parent 589ae94 commit a2ec4fa

File tree

7 files changed

+2
-105
lines changed

7 files changed

+2
-105
lines changed

Ical.Net.Tests/GetOccurrenceTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public void EnumerationChangedException()
145145

146146
var calendar = GetCalendars(ical);
147147
var date = new DateTime(2016, 10, 11);
148-
var occurrences = calendar.GetOccurrencesOfDay(date).ToList();
148+
var occurrences = calendar.GetOccurrences(date, date.AddDays(1)).ToList();
149149

150150
//We really want to make sure this doesn't explode
151151
Assert.That(occurrences, Has.Count.EqualTo(1));

Ical.Net.Tests/RecurrenceTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3806,7 +3806,7 @@ public void GetOccurrenceShouldExcludeDtEndFloating()
38063806

38073807
var calendar = Calendar.Load(ical);
38083808
// Set start date for occurrences to search to the end date of the event
3809-
var occurrences = calendar.GetOccurrencesOfDay(new CalDateTime(2024, 12, 2));
3809+
var occurrences = calendar.GetOccurrences(new CalDateTime(2024, 12, 2), new CalDateTime(2024, 12, 3));
38103810

38113811
Assert.That(occurrences, Is.Empty);
38123812
}

Ical.Net/Calendar.cs

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -197,24 +197,6 @@ public VTimeZone AddTimeZone(VTimeZone tz)
197197
return tz;
198198
}
199199

200-
201-
/// <summary>
202-
/// Returns a list of occurrences of each recurring component
203-
/// for the date provided (<paramref name="dt"/>).
204-
/// </summary>
205-
/// <param name="dt">The date for which to return occurrences. Time is ignored on this parameter.</param>
206-
/// <returns>A list of occurrences that occur on the given date (<paramref name="dt"/>).</returns>
207-
public virtual IEnumerable<Occurrence> GetOccurrencesOfDay(IDateTime dt)
208-
{
209-
return GetOccurrences<IRecurringComponent>(new CalDateTime(dt.Date), new CalDateTime(dt.Date.AddDays(1)));
210-
}
211-
212-
/// <inheritdoc cref="GetOccurrencesOfDay(IDateTime)"/>
213-
public virtual IEnumerable<Occurrence> GetOccurrencesOfDay(DateTime dt)
214-
{
215-
return GetOccurrences<IRecurringComponent>(new CalDateTime(DateOnly.FromDateTime(dt)), new CalDateTime(DateOnly.FromDateTime(dt.Date.AddDays(1))));
216-
}
217-
218200
/// <summary>
219201
/// Returns a list of occurrences of each recurring component
220202
/// that occur between <paramref name="startTime"/> and <paramref name="endTime"/>.
@@ -229,29 +211,6 @@ public virtual IEnumerable<Occurrence> GetOccurrences(IDateTime startTime = null
229211
public virtual IEnumerable<Occurrence> GetOccurrences(DateTime? startTime, DateTime? endTime)
230212
=> GetOccurrences<IRecurringComponent>(startTime?.AsCalDateTime(), endTime?.AsCalDateTime());
231213

232-
/// <summary>
233-
/// Returns all occurrences of components of type T that start on the date provided.
234-
/// All components starting between 12:00:00AM and 11:59:59 PM will be
235-
/// returned.
236-
/// <note>
237-
/// This will first Evaluate() the date range required in order to
238-
/// determine the occurrences for the date provided, and then return
239-
/// the occurrences.
240-
/// </note>
241-
/// </summary>
242-
/// <param name="dt">The date for which to return occurrences. Time is ignored on this parameter.</param>
243-
/// <returns>A list of Periods representing the occurrences of this object.</returns>
244-
public virtual IEnumerable<Occurrence> GetOccurrences<T>(IDateTime dt) where T : IRecurringComponent
245-
{
246-
return GetOccurrences<T>(new CalDateTime(dt.Date), new CalDateTime(dt.Date.AddDays(1)));
247-
}
248-
249-
/// <inheritdoc cref="GetOccurrencesOfDay(IDateTime)"/>
250-
public virtual IEnumerable<Occurrence> GetOccurrences<T>(DateTime dt) where T : IRecurringComponent
251-
{
252-
return GetOccurrences<T>(new CalDateTime(DateOnly.FromDateTime(dt)), new CalDateTime(DateOnly.FromDateTime(dt.Date.AddDays(1))));
253-
}
254-
255214
/// <inheritdoc cref="GetOccurrences(IDateTime, IDateTime)"/>
256215
public virtual IEnumerable<Occurrence> GetOccurrences<T>(DateTime? startTime, DateTime? endTime) where T : IRecurringComponent
257216
=> GetOccurrences<T>(startTime?.AsCalDateTime(), endTime?.AsCalDateTime());

Ical.Net/CalendarCollection.cs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,6 @@ public static CalendarCollection Load(TextReader tr)
3939
return collection;
4040
}
4141

42-
public HashSet<Occurrence> GetOccurrencesOfDay(IDateTime dt)
43-
{
44-
var occurrences = new HashSet<Occurrence>();
45-
foreach (var iCal in this)
46-
{
47-
occurrences.UnionWith(iCal.GetOccurrencesOfDay(dt));
48-
}
49-
return occurrences;
50-
}
51-
5242
private IEnumerable<Occurrence> GetOccurrences(Func<Calendar, IEnumerable<Occurrence>> f)
5343
=>
5444

@@ -65,21 +55,12 @@ private IEnumerable<Occurrence> GetOccurrences(Func<Calendar, IEnumerable<Occurr
6555
// being ordered to avoid full enumeration.
6656
.OrderedMergeMany();
6757

68-
public IEnumerable<Occurrence> GetOccurrencesOfDay(DateTime dt)
69-
=> GetOccurrences(iCal => iCal.GetOccurrencesOfDay(dt));
70-
7158
public IEnumerable<Occurrence> GetOccurrences(IDateTime startTime, IDateTime endTime)
7259
=> GetOccurrences(iCal => iCal.GetOccurrences(startTime, endTime));
7360

7461
public IEnumerable<Occurrence> GetOccurrences(DateTime? startTime, DateTime? endTime)
7562
=> GetOccurrences(iCal => iCal.GetOccurrences(startTime, endTime));
7663

77-
public IEnumerable<Occurrence> GetOccurrences<T>(IDateTime dt) where T : IRecurringComponent
78-
=> GetOccurrences(iCal => iCal.GetOccurrencesOfDay(dt));
79-
80-
public IEnumerable<Occurrence> GetOccurrences<T>(DateTime dt) where T : IRecurringComponent
81-
=> GetOccurrences(iCal => iCal.GetOccurrences<T>(dt));
82-
8364
public IEnumerable<Occurrence> GetOccurrences<T>(IDateTime startTime, IDateTime endTime) where T : IRecurringComponent
8465
=> GetOccurrences(iCal => iCal.GetOccurrences<T>(startTime, endTime));
8566

Ical.Net/CalendarComponents/RecurringComponent.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,6 @@ protected override void OnDeserializing(StreamingContext context)
178178
Initialize();
179179
}
180180

181-
public virtual IEnumerable<Occurrence> GetOccurrencesOfDay(IDateTime dt) => RecurrenceUtil.GetOccurrences(this, dt, EvaluationIncludesReferenceDate);
182-
183-
public virtual IEnumerable<Occurrence> GetOccurrencesOfDay(DateTime dt)
184-
=> RecurrenceUtil.GetOccurrences(this, new CalDateTime(dt), EvaluationIncludesReferenceDate);
185-
186181
public virtual IEnumerable<Occurrence> GetOccurrences(IDateTime startTime, IDateTime endTime)
187182
=> RecurrenceUtil.GetOccurrences(this, startTime, endTime, EvaluationIncludesReferenceDate);
188183

Ical.Net/IGetOccurrences.cs

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,6 @@ namespace Ical.Net;
1212

1313
public interface IGetOccurrences
1414
{
15-
/// <summary>
16-
/// Returns all occurrences of this component that start on the date provided.
17-
/// All components starting between 12:00:00AM and 11:59:59 PM will be
18-
/// returned.
19-
/// <note>
20-
/// This will first Evaluate() the date range required in order to
21-
/// determine the occurrences for the date provided, and then return
22-
/// the occurrences.
23-
/// </note>
24-
/// </summary>
25-
/// <param name="dt">The date for which to return occurrences.</param>
26-
/// <returns>An IEnumerable that calculates and returns Periods representing the occurrences of this object in ascending order.</returns>
27-
IEnumerable<Occurrence> GetOccurrencesOfDay(IDateTime dt);
28-
29-
IEnumerable<Occurrence> GetOccurrencesOfDay(DateTime dt);
30-
3115
/// <summary>
3216
/// Returns all occurrences of this component that overlap with the date range provided.
3317
/// All components that overlap with the time range between <paramref name="startTime"/> and <paramref name="endTime"/> will be returned.
@@ -42,22 +26,6 @@ public interface IGetOccurrences
4226

4327
public interface IGetOccurrencesTyped : IGetOccurrences
4428
{
45-
/// <summary>
46-
/// Returns all occurrences of components of type T that start on the date provided.
47-
/// All components starting between 12:00:00AM and 11:59:59 PM will be
48-
/// returned.
49-
/// <note>
50-
/// This will first Evaluate() the date range required in order to
51-
/// determine the occurrences for the date provided, and then return
52-
/// the occurrences.
53-
/// </note>
54-
/// </summary>
55-
/// <param name="dt">The date for which to return occurrences.</param>
56-
/// <returns>An IEnumerable that calculates and returns Periods representing the occurrences of this object in ascending order.</returns>
57-
IEnumerable<Occurrence> GetOccurrences<T>(IDateTime dt) where T : IRecurringComponent;
58-
59-
IEnumerable<Occurrence> GetOccurrences<T>(DateTime dt) where T : IRecurringComponent;
60-
6129
/// <summary>
6230
/// Returns all occurrences of components of type T that start within the date range provided.
6331
/// All components occurring between <paramref name="startTime"/> and <paramref name="endTime"/>

Ical.Net/VTimeZoneInfo.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,6 @@ public virtual IDateTime RecurrenceId
172172
set => Properties.Set("RECURRENCE-ID", value);
173173
}
174174

175-
public virtual IEnumerable<Occurrence> GetOccurrencesOfDay(IDateTime dt)
176-
=> RecurrenceUtil.GetOccurrences(this, dt, true);
177-
178-
public virtual IEnumerable<Occurrence> GetOccurrencesOfDay(DateTime dt)
179-
=> RecurrenceUtil.GetOccurrences(this, new CalDateTime(dt), true);
180-
181175
public virtual IEnumerable<Occurrence> GetOccurrences(IDateTime startTime, IDateTime endTime)
182176
=> RecurrenceUtil.GetOccurrences(this, startTime, endTime, true);
183177

0 commit comments

Comments
 (0)