Skip to content

Commit

Permalink
G->O: Create recurrence.
Browse files Browse the repository at this point in the history
New Outlook.Graph/O365Recurrence.cs
DateTime extension methods for Graph dates.
#2017
  • Loading branch information
phw198 committed Dec 8, 2024
1 parent ecaf116 commit e64f09a
Show file tree
Hide file tree
Showing 3 changed files with 455 additions and 1 deletion.
16 changes: 16 additions & 0 deletions src/OutlookGoogleCalendarSync/Extensions/DateTime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ public static System.DateTime SafeDateTime(this EventDateTime evDt) {
return evDt.DateTime ?? System.DateTime.Parse(evDt.Date);
}

/// <summary>
/// Returns the DateTime for a Graph Date
/// </summary>
/// <returns>DateTime</returns>
public static System.DateTime SafeDateTime(this Microsoft.Graph.Date graphDate) {
return new System.DateTime(graphDate.Year, graphDate.Month, graphDate.Day);
}

/// <summary>
/// Parses the DateTimeTimeZone string to a local DateTime
/// </summary>
Expand All @@ -76,6 +84,14 @@ public static System.DateTime SafeDateTime(this Microsoft.Graph.DateTimeTimeZone
return safeDate;
}

/// <summary>
/// Converts a System.DateTime to a Graph.Date
/// </summary>
/// <returns>Graph.Date</returns>
public static Microsoft.Graph.Date ToGraphDate(this System.DateTime dt) {
return new Microsoft.Graph.Date(dt.Year, dt.Month, dt.Day);
}

/// <summary>
/// Whether an Event is all day
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ private void createCalendarEntry(GcalData.Event ev, ref Microsoft.Graph.Event ai
ai.End.DateTime = ev.End.SafeDateTime().AddMinutes(offset).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss");
}

//Recurrence.Instance.BuildOutlookPattern(ev, ai);
ai.Recurrence = Recurrence.BuildOutlookPattern(ev);

ai.Subject = Obfuscate.ApplyRegex(Obfuscate.Property.Subject, ev.Summary, null, Sync.Direction.GoogleToOutlook);
if (profile.AddDescription && ev.Description != null) {
Expand Down
Loading

0 comments on commit e64f09a

Please sign in to comment.