Skip to content

Commit

Permalink
Fixed datetime exception
Browse files Browse the repository at this point in the history
  • Loading branch information
VILLAN3LL3 committed Dec 5, 2021
1 parent d934ec5 commit 8710b97
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions Orso.Arpa.Domain/Logic/Appointments/DateHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ public static DateTime LastDayOfMonth(DateTime date)
private static DateTime FirstDayOfWeek(DateTime date)
{
int diff = (7 + (date.DayOfWeek - DayOfWeek.Monday)) % 7;
return date.AddDays(-1 * diff).Date;
DateTime firstDay = date.AddDays(-1 * diff);
return new DateTime(firstDay.Year, firstDay.Month, firstDay.Day, 0, 0, 0, DateTimeKind.Local);
}

private static DateTime LastDayOfWeek(DateTime date)
Expand All @@ -34,7 +35,7 @@ public static DateTime GetStartTime(DateTime date, DateRange range)
{
DateRange.Month => FirstDayOfMonth(date),
DateRange.Week => FirstDayOfWeek(date),
DateRange.Day => date.Date,
DateRange.Day => new DateTime(date.Year, date.Month, date.Day, 0, 0, 0, DateTimeKind.Local),
_ => throw new NotSupportedException("Requested DateRange is not supported"),
};
}
Expand Down
2 changes: 1 addition & 1 deletion Orso.Arpa.Persistence/Orso.Arpa.Persistence.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<PackageReference Include="HotChocolate.Types" Version="12.3.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="6.0.0" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="6.0.0" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="6.0.1" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit 8710b97

Please sign in to comment.