Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## [2.0.2](https://github.com/sondresjolyst/garge-api/compare/v2.0.1...v2.0.2) (2026-04-19)


### Bug Fixes

* **electricity:** normalize date parsing to prevent timezone-dependent duplicates ([#103](https://github.com/sondresjolyst/garge-api/issues/103)) ([cf90a26](https://github.com/sondresjolyst/garge-api/commit/cf90a2614f863c415b78beb3d4bf966a7ec7e8ac))

## [2.0.1](https://github.com/sondresjolyst/garge-api/compare/v2.0.0...v2.0.1) (2026-04-19)


Expand Down
12 changes: 9 additions & 3 deletions Services/NordPoolService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ private void ParsePriceEntries(dynamic json, string dataType, PriceResponse pric

if (json.updatedAt != null)
{
priceResponse.Updated = DateTime.Parse((string)json.updatedAt);
priceResponse.Updated = DateTime.Parse((string)json.updatedAt, CultureInfo.InvariantCulture);
}
else
{
Expand All @@ -118,8 +118,8 @@ private void ParsePriceEntries(dynamic json, string dataType, PriceResponse pric
/// <summary>
/// Parses a NordPool delivery date string to UTC.
/// HOURLY entries use full ISO timestamps (e.g. "2026-04-18T22:00:00Z") — parsed as exact UTC.
/// DAILY/MONTHLY entries use date-only strings (e.g. "2026-04-11")treated as UTC midnight of
/// that calendar date, making storage environment-independent (Docker UTC vs Windows UTC+2).
/// DAILY/MONTHLY entries may arrive as "MM/dd/yyyy HH:mm:ss" or "yyyy-MM-dd"always stored
/// as UTC midnight of that calendar date so results are environment-independent (UTC vs UTC+2).
/// </summary>
private static DateTime ParseDeliveryDate(string raw)
{
Expand All @@ -129,6 +129,12 @@ private static DateTime ParseDeliveryDate(string raw)
return DateTimeOffset.Parse(raw, CultureInfo.InvariantCulture).UtcDateTime;
}

// "MM/dd/yyyy HH:mm:ss" format returned by NordPool
if (DateTime.TryParseExact(raw, "MM/dd/yyyy HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out var dtSlash))
{
return DateTime.SpecifyKind(dtSlash, DateTimeKind.Utc);
}

// Date-only string — always store as UTC midnight of that date
return DateTime.SpecifyKind(
DateTime.ParseExact(raw, "yyyy-MM-dd", CultureInfo.InvariantCulture),
Expand Down
4 changes: 2 additions & 2 deletions garge-api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="9.0.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.3" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.4" />
<PackageReference Include="SendGrid" Version="9.29.3" />
<PackageReference Include="Serilog.AspNetCore" Version="9.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="6.1.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="7.2.0" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.4.0" />
Expand Down
Loading