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
For everyone who is wondering how you need to parse these dates to a DateTime value.
#region CreateDateTime
/// <summary>/// Parses the string to a datetime value or null/// </summary>/// <param name="dateTimeString"></param>/// <returns></returns>privatestaticDateTime?CreateDateTime(stringdateTimeString){try{if(dateTimeString.StartsWith("D:"))dateTimeString=dateTimeString.Substring(2);varmonth=1;varday=1;varhour=0;varminute=0;varsecond=0;intoffsetHour=0,offsetMinute=0;varyear=int.Parse(dateTimeString.Substring(0,4));if(dateTimeString.Length>=6){month=int.Parse(dateTimeString.Substring(4,2));if(dateTimeString.Length>=8){day=int.Parse(dateTimeString.Substring(6,2));if(dateTimeString.Length>=10){hour=int.Parse(dateTimeString.Substring(8,2));if(dateTimeString.Length>=12){minute=int.Parse(dateTimeString.Substring(10,2));if(dateTimeString.Length>=14)second=int.Parse(dateTimeString.Substring(12,2));}}}}vardateTime=newDateTime(year,month,day,hour,minute,second);if(dateTimeString.Length<=14)returndateTime;varvariation=dateTimeString[14];if(variation=='Z')returndateTime.ToLocalTime();if(dateTimeString.Length>=17){offsetHour=int.Parse(dateTimeString.Substring(15,2));if(dateTimeString.Length>=20)offsetMinute=int.Parse(dateTimeString.Substring(18,2));}vartimeSpan=newTimeSpan(offsetHour,offsetMinute,0);if(variation=='-')dateTime+=timeSpan;elsedateTime-=timeSpan;returndateTime.ToLocalTime();}catch(Exceptionexception){returnnull;}}
#endregion
The text was updated successfully, but these errors were encountered:
@Sicos1977 thanks a lot for that. PdfPig already has UglyToad.PdfPig.Util.DateFormatHelper.TryParseDateTimeOffset(...) - it might be worth merging your efforts with what's available?
For everyone who is wondering how you need to parse these dates to a DateTime value.
The text was updated successfully, but these errors were encountered: