set time zone
This commit is contained in:
parent
85a4ecb2aa
commit
86667b661a
1 changed files with 8 additions and 4 deletions
|
|
@ -28,6 +28,8 @@ namespace ShiftScheduler.Services
|
||||||
private readonly string _configDirectory;
|
private readonly string _configDirectory;
|
||||||
private readonly string _shiftsFilePath;
|
private readonly string _shiftsFilePath;
|
||||||
private readonly string _transportFilePath;
|
private readonly string _transportFilePath;
|
||||||
|
|
||||||
|
TimeZoneInfo localTimeZone = TimeZoneInfo.FindSystemTimeZoneById("Europe/Zurich");
|
||||||
|
|
||||||
public ConfigurationService(ApplicationConfiguration initialConfiguration)
|
public ConfigurationService(ApplicationConfiguration initialConfiguration)
|
||||||
{
|
{
|
||||||
|
|
@ -212,13 +214,15 @@ namespace ShiftScheduler.Services
|
||||||
DateTimeOffset? afternoonStart = null;
|
DateTimeOffset? afternoonStart = null;
|
||||||
DateTimeOffset? afternoonEnd = null;
|
DateTimeOffset? afternoonEnd = null;
|
||||||
|
|
||||||
|
TimeSpan offset = localTimeZone.GetUtcOffset(DateTime.UtcNow);
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(shift.MorningTime))
|
if (!string.IsNullOrEmpty(shift.MorningTime))
|
||||||
{
|
{
|
||||||
var times = shift.MorningTime.Split('-');
|
var times = shift.MorningTime.Split('-');
|
||||||
if (times.Length == 2)
|
if (times.Length == 2)
|
||||||
{
|
{
|
||||||
var start = $"{date:yyyy-MM-dd}T{times[0]}:00";
|
var start = $"{date:yyyy-MM-dd}T{times[0]}:00+{offset.Hours}:{offset.Minutes}";
|
||||||
var end = $"{date:yyyy-MM-dd}T{times[1]}:00";
|
var end = $"{date:yyyy-MM-dd}T{times[1]}:00+{offset.Hours}:{offset.Minutes}";
|
||||||
morningStart = DateTimeOffset.Parse(start);
|
morningStart = DateTimeOffset.Parse(start);
|
||||||
morningEnd = DateTimeOffset.Parse(end);
|
morningEnd = DateTimeOffset.Parse(end);
|
||||||
}
|
}
|
||||||
|
|
@ -229,8 +233,8 @@ namespace ShiftScheduler.Services
|
||||||
var times = shift.AfternoonTime.Split('-');
|
var times = shift.AfternoonTime.Split('-');
|
||||||
if (times.Length == 2)
|
if (times.Length == 2)
|
||||||
{
|
{
|
||||||
var start = $"{date:yyyy-MM-dd}T{times[0]}:00";
|
var start = $"{date:yyyy-MM-dd}T{times[0]}:00+{offset.Hours}:{offset.Minutes}";
|
||||||
var end = $"{date:yyyy-MM-dd}T{times[1]}:00";
|
var end = $"{date:yyyy-MM-dd}T{times[1]}:00+{offset.Hours}:{offset.Minutes}";
|
||||||
afternoonStart = DateTimeOffset.Parse(start);
|
afternoonStart = DateTimeOffset.Parse(start);
|
||||||
afternoonEnd = DateTimeOffset.Parse(end);
|
afternoonEnd = DateTimeOffset.Parse(end);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue