-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐛 16 fix bug to do with timestamps when running in docker (#17)
* Added SydneyTimeProvider * Remove weather component * Removed usages of DateTime.Now * Register SydneyTimeProvider * Added unit tests * Refactored get timesheet to use common utc calculation * Refactored timesheet query to use common UTC logic * Tidy up from review
- Loading branch information
1 parent
1c1fefb
commit 262c00f
Showing
17 changed files
with
224 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
{ | ||
"sdk": { | ||
"version": "8.0.100", | ||
"rollForward": "latestMinor" | ||
"version": "8.0.0", | ||
"rollForward": "latestFeature", | ||
"allowPrerelease": false | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace WebUI.Common.Services; | ||
|
||
public class SydneyTimeProvider : TimeProvider | ||
{ | ||
private const string Timezone = "AUS Eastern Standard Time"; | ||
|
||
private readonly TimeZoneInfo _sydneyTimeZone = TimeZoneInfo.FindSystemTimeZoneById(Timezone); | ||
|
||
public override TimeZoneInfo LocalTimeZone => _sydneyTimeZone; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
namespace WebUI.Common.Services; | ||
|
||
public static class TimeProviderExt | ||
{ | ||
public static DateOnly GetToday(this TimeProvider timeProvider) | ||
{ | ||
var now = timeProvider.GetLocalNow(); | ||
return DateOnly.FromDateTime(now.Date); | ||
} | ||
|
||
public static DateTime GetStartOfDayUtc(this TimeProvider timeProvider, DateOnly date) | ||
{ | ||
var timeZone = timeProvider.LocalTimeZone; | ||
|
||
// Find the start of the day in Sydney time | ||
var startOfDaySydney = date.ToDateTime(TimeOnly.MinValue); | ||
|
||
// Convert the start of the day to UTC | ||
var startOfDayUtc = TimeZoneInfo.ConvertTimeToUtc(startOfDaySydney, timeZone); | ||
|
||
return startOfDayUtc; | ||
} | ||
|
||
public static DateTime GetEndOfDayUtc(this TimeProvider timeProvider, DateOnly date) | ||
{ | ||
var timeZone = timeProvider.LocalTimeZone; | ||
|
||
// Find the start of the day in Sydney time | ||
var endOfDaySydney = date.ToDateTime(TimeOnly.MaxValue); | ||
|
||
// Convert the start of the day to UTC | ||
var endOfDayUtc = TimeZoneInfo.ConvertTimeToUtc(endOfDaySydney, timeZone); | ||
|
||
return endOfDayUtc; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
19 changes: 19 additions & 0 deletions
19
src/WebUI/Features/DailyScrum/Components/Pages/Debug.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
@page "/daily-scrum/debug" | ||
@using Microsoft.AspNetCore.Components.Web | ||
@inject TimeProvider TimeProvider | ||
|
||
<PageTitle>Daily Scrum</PageTitle> | ||
|
||
<h1>Daily Scrum - Debug</h1> | ||
|
||
<p>Now - @_now</p> | ||
|
||
@code { | ||
private DateTimeOffset _now; | ||
|
||
protected override void OnInitialized() | ||
{ | ||
_now = TimeProvider.GetLocalNow(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.