Skip to content

Commit

Permalink
Merge pull request #18 from yizshi/fix_time
Browse files Browse the repository at this point in the history
Not convert Date when given date already in UTC DateTimeKind
  • Loading branch information
AaronAtDuo authored Dec 8, 2022
2 parents 63b916e + e4f3575 commit aad7505
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion duo_api_csharp/Duo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,12 @@ private static string DateToRFC822(DateTime date)
// between the offset's hours and minutes.
string date_string = date.ToString(
"ddd, dd MMM yyyy HH:mm:ss", CultureInfo.InvariantCulture);
int offset = TimeZoneInfo.Local.GetUtcOffset(date).Hours;
int offset = 0;
// set offset if input date is not UTC time.
if (date.Kind != DateTimeKind.Utc)
{
offset = TimeZoneInfo.Local.GetUtcOffset(date).Hours;
}
string zone;
// + or -, then 0-pad, then offset, then more 0-padding.
if (offset < 0)
Expand Down

0 comments on commit aad7505

Please sign in to comment.