Skip to content

Commit

Permalink
add - doc - Added different time and date parsers
Browse files Browse the repository at this point in the history
---

We've added different types of parsers.

---

Type: add
Breaking: False
Doc Required: True
Backport Required: False
Part: 1/1
  • Loading branch information
AptiviCEO committed Oct 1, 2024
1 parent ca64e59 commit 96860e8
Show file tree
Hide file tree
Showing 20 changed files with 199 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ internal override string ToStringVcalendarInternal(Version cardVersion) =>
internal override BaseCalendarPartInfo FromStringVcalendarInternal(string value, string[] finalArgs, string[] elementTypes, string valueType, Version cardVersion)
{
// Populate the fields
DateTimeOffset created = VcardCommonTools.ParsePosixDate(value);
DateTimeOffset created = VcardCommonTools.ParsePosixDateTime(value);

// Add the fetched information
DateCreatedInfo _time = new(finalArgs, elementTypes, valueType, created);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ internal override string ToStringVcalendarInternal(Version cardVersion) =>
internal override BaseCalendarPartInfo FromStringVcalendarInternal(string value, string[] finalArgs, string[] elementTypes, string valueType, Version cardVersion)
{
// Populate the fields
DateTimeOffset end = VcardCommonTools.ParsePosixDate(value);
DateTimeOffset end = VcardCommonTools.ParsePosixDateTime(value);

// Add the fetched information
DateEndInfo _time = new(finalArgs, elementTypes, valueType, end);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ internal override string ToStringVcalendarInternal(Version cardVersion) =>
internal override BaseCalendarPartInfo FromStringVcalendarInternal(string value, string[] finalArgs, string[] elementTypes, string valueType, Version cardVersion)
{
// Populate the fields
DateTimeOffset stamp = VcardCommonTools.ParsePosixDate(value);
DateTimeOffset stamp = VcardCommonTools.ParsePosixDateTime(value);

// Add the fetched information
DateStampInfo _time = new(finalArgs, elementTypes, valueType, stamp);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ internal override string ToStringVcalendarInternal(Version cardVersion) =>
internal override BaseCalendarPartInfo FromStringVcalendarInternal(string value, string[] finalArgs, string[] elementTypes, string valueType, Version cardVersion)
{
// Populate the fields
DateTimeOffset start = VcardCommonTools.ParsePosixDate(value);
DateTimeOffset start = VcardCommonTools.ParsePosixDateTime(value);

// Add the fetched information
DateStartInfo _time = new(finalArgs, elementTypes, valueType, start);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ internal override string ToStringVcalendarInternal(Version cardVersion) =>
internal override BaseCalendarPartInfo FromStringVcalendarInternal(string value, string[] finalArgs, string[] elementTypes, string valueType, Version cardVersion)
{
// Populate the fields
DateTimeOffset created = VcardCommonTools.ParsePosixDate(value);
DateTimeOffset created = VcardCommonTools.ParsePosixDateTime(value);

// Add the fetched information
LastModifiedInfo _time = new(finalArgs, elementTypes, valueType, created);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ internal override BaseCalendarPartInfo FromStringVcalendarInternal(string value,
string audioResource = split[3];

// Process the run time and the repeat times
DateTimeOffset runTime = VcardCommonTools.ParsePosixDate(unprocessedRunTime);
DateTimeOffset runTime = VcardCommonTools.ParsePosixDateTime(unprocessedRunTime);
int repeat = 0;
if (!string.IsNullOrWhiteSpace(unprocessedRepeat) && !int.TryParse(unprocessedRepeat, out repeat))
throw new ArgumentException("Invalid repeat times");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ internal override BaseCalendarPartInfo FromStringVcalendarInternal(string value,

// Process the UTC offset and start/end dates
TimeSpan utcOffset = VcardCommonTools.ParseUtcOffset(unprocessedUtc);
DateTimeOffset startDate = VcardCommonTools.ParsePosixDate(unprocessedStart);
DateTimeOffset endDate = VcardCommonTools.ParsePosixDate(unprocessedEnd);
DateTimeOffset startDate = VcardCommonTools.ParsePosixDateTime(unprocessedStart);
DateTimeOffset endDate = VcardCommonTools.ParsePosixDateTime(unprocessedEnd);

// Populate the fields
DaylightInfo _geo = new(finalArgs, elementTypes, valueType, true, utcOffset, startDate, endDate, standard, daylight);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ internal override BaseCalendarPartInfo FromStringVcalendarInternal(string value,
string display = split[3];

// Process the run time and the repeat times
DateTimeOffset runTime = VcardCommonTools.ParsePosixDate(unprocessedRunTime);
DateTimeOffset runTime = VcardCommonTools.ParsePosixDateTime(unprocessedRunTime);
int repeat = 0;
if (!string.IsNullOrWhiteSpace(unprocessedRepeat) && !int.TryParse(unprocessedRepeat, out repeat))
throw new ArgumentException("Invalid repeat times");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ internal override BaseCalendarPartInfo FromStringVcalendarInternal(string value,
string note = split[4];

// Process the run time and the repeat times
DateTimeOffset runTime = VcardCommonTools.ParsePosixDate(unprocessedRunTime);
DateTimeOffset runTime = VcardCommonTools.ParsePosixDateTime(unprocessedRunTime);
int repeat = 0;
if (!string.IsNullOrWhiteSpace(unprocessedRepeat) && !int.TryParse(unprocessedRepeat, out repeat))
throw new ArgumentException("Invalid repeat times");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ internal override BaseCalendarPartInfo FromStringVcalendarInternal(string value,
string procedure = split[3];

// Process the run time and the repeat times
DateTimeOffset runTime = VcardCommonTools.ParsePosixDate(unprocessedRunTime);
DateTimeOffset runTime = VcardCommonTools.ParsePosixDateTime(unprocessedRunTime);
int repeat = 0;
if (!string.IsNullOrWhiteSpace(unprocessedRepeat) && !int.TryParse(unprocessedRepeat, out repeat))
throw new ArgumentException("Invalid repeat times");
Expand Down
4 changes: 2 additions & 2 deletions VisualCard.Calendar/Parts/Implementations/RecDateInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ internal override BaseCalendarPartInfo FromStringVcalendarInternal(string value,
var recDateStrings = Regex.Unescape(value).Split(';');
recDates = recDateStrings.Select((date) =>
{
var parsedDate = VcardCommonTools.ParsePosixDate(date);
var parsedDate = VcardCommonTools.ParsePosixDateTime(date);
return new TimePeriod(parsedDate, parsedDate);
}).ToArray();
}
Expand All @@ -82,7 +82,7 @@ internal override BaseCalendarPartInfo FromStringVcalendarInternal(string value,
catch
{
// Not a period. Continue using normal date and time
var parsedDate = VcardCommonTools.ParsePosixDate(value);
var parsedDate = VcardCommonTools.ParsePosixDateTime(value);
recDates = [new TimePeriod(parsedDate, parsedDate)];
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ internal override string ToStringVcalendarInternal(Version cardVersion) =>
internal override BaseCalendarPartInfo FromStringVcalendarInternal(string value, string[] finalArgs, string[] elementTypes, string valueType, Version cardVersion)
{
// Populate the fields
DateTimeOffset completed = VcardCommonTools.ParsePosixDate(value);
DateTimeOffset completed = VcardCommonTools.ParsePosixDateTime(value);

// Add the fetched information
DateCompletedInfo _time = new(finalArgs, elementTypes, valueType, completed);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ internal override string ToStringVcalendarInternal(Version cardVersion) =>
internal override BaseCalendarPartInfo FromStringVcalendarInternal(string value, string[] finalArgs, string[] elementTypes, string valueType, Version cardVersion)
{
// Populate the fields
DateTimeOffset completed = VcardCommonTools.ParsePosixDate(value);
DateTimeOffset completed = VcardCommonTools.ParsePosixDateTime(value);

// Add the fetched information
DueDateInfo _time = new(finalArgs, elementTypes, valueType, completed);
Expand Down
2 changes: 1 addition & 1 deletion VisualCard/Parsers/Recurrence/RecurrenceParserV1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public static RecurrenceRule[] ParseRuleV1(string rule)
}

// Is this designator an optional enddate?
if (VcardCommonTools.TryParsePosixDate(filtered, out DateTimeOffset endDate) && i == designators.Length - 1)
if (VcardCommonTools.TryParsePosixDateTime(filtered, out DateTimeOffset endDate) && i == designators.Length - 1)
{
// Check to see if this rule is the only rule
if (rules.Count == 0)
Expand Down
2 changes: 1 addition & 1 deletion VisualCard/Parsers/Recurrence/RecurrenceParserV2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public static RecurrenceRule ParseRuleV2(string rule)
case "UNTIL":
// ( "UNTIL" "=" enddate )
// enddate = date / date-time
DateTimeOffset dateTime = VcardCommonTools.ParsePosixDate(valueRepresentation);
DateTimeOffset dateTime = VcardCommonTools.ParsePosixDateTime(valueRepresentation);
recurrenceRule.endDate = dateTime;
break;
case "COUNT":
Expand Down
Loading

0 comments on commit 96860e8

Please sign in to comment.