Skip to content

Commit

Permalink
temp DST fix
Browse files Browse the repository at this point in the history
  • Loading branch information
myangelkamikaze committed May 8, 2019
1 parent 259ecf1 commit 3be6f2b
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions ElectronicObserver/Resource/Record/ResourceRecord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,11 @@ public ResourceElement GetRecord(DateTime target)
/// </summary>
public ResourceElement GetRecordPrevious()
{
DateTime now = DateTime.Now;
bool isDst = TimeZoneInfo.Local.IsDaylightSavingTime(now);

now = DateTime.UtcNow + new TimeSpan(9, 0, 0);

DateTime now = DateTime.UtcNow + new TimeSpan(9, 0, 0);
DateTime target;
if (now.TimeOfDay.Hours < 2)
{
Expand All @@ -255,17 +258,23 @@ public ResourceElement GetRecordPrevious()
target = new DateTime(now.Year, now.Month, now.Day, 14, 0, 0);
}

return GetRecord(target.Add(DateTimeHelper.GetTimeDifference()));
if(isDst)
target += new TimeSpan(1, 0, 0);

return GetRecord(target.Add(DateTimeHelper.GetTimeDifference()));
}

/// <summary>
/// 今日の戦果更新以降の最も古い記録を返します。
/// </summary>
public ResourceElement GetRecordDay()
{
DateTime now = DateTime.Now;
bool isDst = TimeZoneInfo.Local.IsDaylightSavingTime(now);

DateTime now = DateTime.UtcNow + new TimeSpan(9, 0, 0);
DateTime target;
now = DateTime.UtcNow + new TimeSpan(9, 0, 0);

DateTime target;
if (now.TimeOfDay.Hours < 2)
{
target = new DateTime(now.Year, now.Month, now.Day, 2, 0, 0).Subtract(TimeSpan.FromDays(1));
Expand All @@ -275,9 +284,13 @@ public ResourceElement GetRecordDay()
target = new DateTime(now.Year, now.Month, now.Day, 2, 0, 0);
}

return GetRecord(target.Add(DateTimeHelper.GetTimeDifference()));
if (isDst)
target += new TimeSpan(1, 0, 0);

return GetRecord(target.Add(DateTimeHelper.GetTimeDifference()));
}


/// <summary>
/// 今月の戦果更新以降の最も古い記録を返します。
/// </summary>
Expand Down

0 comments on commit 3be6f2b

Please sign in to comment.