Skip to content

Commit

Permalink
Merge pull request #92 from Worth-NL/maintenance/UI_dateFormat_adjust
Browse files Browse the repository at this point in the history
Maintenance/UI date format adjust
  • Loading branch information
Thomas-M-Krystyan authored Nov 13, 2024
2 parents 0cdbf3e + d10cd49 commit 246d23d
Show file tree
Hide file tree
Showing 11 changed files with 66 additions and 36 deletions.
2 changes: 1 addition & 1 deletion Documentation/OMC - Documentation.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<h1 id="start">OMC Documentation</h1>

v.1.12.2
v.1.12.3

© 2023-2024, Worth Systems.

Expand Down
2 changes: 1 addition & 1 deletion EventsHandler/Api/EventsHandler/Constants/DefaultValues.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ internal static class ApiController
{
internal const string Route = "[controller]";

internal const string Version = "1.122";
internal const string Version = "1.123";
}
#endregion

Expand Down
4 changes: 2 additions & 2 deletions EventsHandler/Api/EventsHandler/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
COPY ["EventsHandler/Api/EventsHandler/EventsHandler.csproj", "EventsHandler/Api/EventsHandler/"]
RUN dotnet restore "EventsHandler/Api/EventsHandler/EventsHandler.csproj"
Expand Down
19 changes: 17 additions & 2 deletions EventsHandler/Api/EventsHandler/Extensions/DateTimeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ internal static class DateTimeExtensions
{
private static readonly TimeZoneInfo s_cetTimeZone = TimeZoneInfo.FindSystemTimeZoneById("Central European Standard Time");
private static readonly CultureInfo s_dutchCulture = new("nl-NL");
private const string DutchDateFormat = "dd-MM-yyyy";

/// <summary>
/// Converts the given <see cref="DateTime"/> into a <see langword="string"/> representation of the local (Dutch) date.
/// </summary>
/// <param name="dateTime">The source date time.</param>
/// <returns>
/// The <see langword="string"/> representation of a date in the following format:
/// <code>2024-09-15</code>
/// <code>15-09-2024</code>
/// </returns>
internal static string ConvertToDutchDateString(this DateTime dateTime)
{
Expand All @@ -29,7 +30,21 @@ internal static string ConvertToDutchDateString(this DateTime dateTime)
}

// Formatting the date and time
return dateTime.ToString("yyyy-MM-dd", s_dutchCulture);
return dateTime.ToString(DutchDateFormat, s_dutchCulture);
}

/// <summary>
/// Converts the given <see cref="DateOnly"/> into a <see langword="string"/> representation of the local (Dutch) date.
/// </summary>
/// <param name="date">The source date.</param>
/// <returns>
/// The <see langword="string"/> representation of a date in the following format:
/// <code>15-09-2024</code>
/// </returns>
internal static string ConvertToDutchDateString(this DateOnly date)
{
// Formatting the date and time
return date.ToString(DutchDateFormat, s_dutchCulture);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,15 @@ protected override Dictionary<string, object> GetEmailPersonalization(CommonPart
s_emailPersonalization["klant.achternaam"] = partyData.Surname;

s_emailPersonalization["besluit.identificatie"] = this._decision.Identification;
s_emailPersonalization["besluit.datum"] = $"{this._decision.Date:O}";
s_emailPersonalization["besluit.datum"] = $"{this._decision.Date.ConvertToDutchDateString()}";
s_emailPersonalization["besluit.toelichting"] = this._decision.Explanation;
s_emailPersonalization["besluit.bestuursorgaan"] = this._decision.GoverningBody;
s_emailPersonalization["besluit.ingangsdatum"] = $"{this._decision.EffectiveDate:O}";
s_emailPersonalization["besluit.vervaldatum"] = $"{this._decision.ExpirationDate:O}";
s_emailPersonalization["besluit.ingangsdatum"] = $"{this._decision.EffectiveDate.ConvertToDutchDateString()}";
s_emailPersonalization["besluit.vervaldatum"] = $"{this._decision.ExpirationDate.ConvertToDutchDateString()}";
s_emailPersonalization["besluit.vervalreden"] = this._decision.ExpirationReason;
s_emailPersonalization["besluit.publicatiedatum"] = $"{this._decision.PublicationDate:O}";
s_emailPersonalization["besluit.verzenddatum"] = $"{this._decision.ShippingDate:O}";
s_emailPersonalization["besluit.uiterlijkereactiedatum"] = $"{this._decision.ResponseDate:O}";
s_emailPersonalization["besluit.publicatiedatum"] = $"{this._decision.PublicationDate.ConvertToDutchDateString()}";
s_emailPersonalization["besluit.verzenddatum"] = $"{this._decision.ShippingDate.ConvertToDutchDateString()}";
s_emailPersonalization["besluit.uiterlijkereactiedatum"] = $"{this._decision.ResponseDate.ConvertToDutchDateString()}";

s_emailPersonalization["besluittype.omschrijving"] = this._decisionType.Name;
s_emailPersonalization["besluittype.omschrijvingGeneriek"] = this._decisionType.Description;
Expand All @@ -160,7 +160,7 @@ protected override Dictionary<string, object> GetEmailPersonalization(CommonPart

s_emailPersonalization["zaak.identificatie"] = this._case.Identification;
s_emailPersonalization["zaak.omschrijving"] = this._case.Name;
s_emailPersonalization["zaak.registratiedatum"] = $"{this._case.RegistrationDate:O}";
s_emailPersonalization["zaak.registratiedatum"] = $"{this._case.RegistrationDate.ConvertToDutchDateString()}";

s_emailPersonalization["zaaktype.omschrijving"] = this._caseType.Name;
s_emailPersonalization["zaaktype.omschrijvingGeneriek"] = this._caseType.Description;
Expand Down Expand Up @@ -284,7 +284,7 @@ private string PrepareDataJson(string subject, string body, string commaSeparate

return $"\"onderwerp\":\"{(subject.IsNullOrEmpty() ? missing : subject)}\"," +
$"\"berichtTekst\":\"{(body.IsNullOrEmpty() ? missing : body)}\"," +
$"\"publicatiedatum\":\"{this._decision.PublicationDate:O}\"," +
$"\"publicatiedatum\":\"{this._decision.PublicationDate.ConvertToDutchDateString()}\"," +
$"\"referentie\":\"{this._decisionResource.DecisionUri}\"," +
$"\"handelingsperspectief\":\"informatie verstrekken\"," +
$"\"geopend\":false," +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ protected override Dictionary<string, object> GetEmailPersonalization(CommonPart
private static string GetFormattedExpirationDate(bool isValid, DateTime expirationDate)
{
return isValid
? expirationDate.ConvertToDutchDateString() // 2001-01-01
? expirationDate.ConvertToDutchDateString() // 01-01-2001
: DefaultValues.Models.DefaultEnumValueName;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// © 2024, Worth Systems.

using EventsHandler.Extensions;
using System.Text.Json;
using System.Text.Json.Serialization;

Expand All @@ -26,7 +27,7 @@ public override DateTime Read(ref Utf8JsonReader reader, Type typeToConvert, Jso
/// <inheritdoc cref="JsonConverter{TValue}.Write(Utf8JsonWriter, TValue, JsonSerializerOptions)"/>
public override void Write(Utf8JsonWriter writer, DateTime value, JsonSerializerOptions options)
{
writer.WriteStringValue($"{value:O}");
writer.WriteStringValue($"{value.ConvertToDutchDateString()}");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ public void ConvertToDutchDateString_LocalDutchDateTime_ReturnsExpectedLocalDutc

private static IEnumerable<(string Id, DateTime DateTime, string ExpectedResult)> GetDateTimeCases()
{
yield return ("#1", DateTime.MinValue, "0001-01-01");
yield return ("#2", DateTime.MaxValue, "9999-12-31");
yield return ("#3", new DateTime(2024, 09, 19, 14, 10, 00), "2024-09-19");
yield return ("#1", DateTime.MinValue, "01-01-0001");
yield return ("#2", DateTime.MaxValue, "31-12-9999");
yield return ("#3", new DateTime(2024, 09, 19, 14, 10, 00), "19-09-2024");
}

[Test]
Expand All @@ -34,7 +34,20 @@ public void ConvertToDutchDateString_UtcDateTime_ReturnsExpectedLocalDutchDateSt
string actualResult = utcTime.ConvertToDutchDateString();

// Assert
Assert.That(actualResult, Is.EqualTo("2025-01-01")); // NOTE: UTC time is behind the local Dutch time
Assert.That(actualResult, Is.EqualTo("01-01-2025")); // NOTE: UTC time is behind the local Dutch time
}

[Test]
public void ConvertToDutchDateString_DateOnly_ReturnsExpectedLocalDutchDateString()
{
// Arrange
DateOnly date = new(2024, 12, 31);

// Act
string actualResult = date.ConvertToDutchDateString();

// Assert
Assert.That(actualResult, Is.EqualTo("31-12-2024"));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -303,15 +303,15 @@ public async Task GetPersonalizationAsync_ReturnsExpectedPersonalization(Distrib
$"\"klant.voorvoegselAchternaam\":null," +
$"\"klant.achternaam\":\"Chan\"," +
$"\"besluit.identificatie\":\"\"," +
$"\"besluit.datum\":\"0001-01-01\"," +
$"\"besluit.datum\":\"01-01-0001\"," +
$"\"besluit.toelichting\":\"\"," +
$"\"besluit.bestuursorgaan\":\"\"," +
$"\"besluit.ingangsdatum\":\"0001-01-01\"," +
$"\"besluit.vervaldatum\":\"0001-01-01\"," +
$"\"besluit.ingangsdatum\":\"01-01-0001\"," +
$"\"besluit.vervaldatum\":\"01-01-0001\"," +
$"\"besluit.vervalreden\":\"\"," +
$"\"besluit.publicatiedatum\":\"0001-01-01\"," +
$"\"besluit.verzenddatum\":\"0001-01-01\"," +
$"\"besluit.uiterlijkereactiedatum\":\"0001-01-01\"," +
$"\"besluit.publicatiedatum\":\"01-01-0001\"," +
$"\"besluit.verzenddatum\":\"01-01-0001\"," +
$"\"besluit.uiterlijkereactiedatum\":\"01-01-0001\"," +
$"\"besluittype.omschrijving\":\"\"," +
$"\"besluittype.omschrijvingGeneriek\":\"\"," +
$"\"besluittype.besluitcategorie\":\"\"," +
Expand All @@ -320,7 +320,7 @@ public async Task GetPersonalizationAsync_ReturnsExpectedPersonalization(Distrib
$"\"besluittype.toelichting\":\"\"," +
$"\"zaak.identificatie\":\"ZAAK-2024-00000000001\"," +
$"\"zaak.omschrijving\":\"\"," +
$"\"zaak.registratiedatum\":\"0001-01-01\"," +
$"\"zaak.registratiedatum\":\"01-01-0001\"," +
$"\"zaaktype.omschrijving\":\"\"," +
$"\"zaaktype.omschrijvingGeneriek\":\"\"" +
$"}}";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,14 +323,14 @@ public async Task TryGetDataAsync_ValidTaskType_Open_AssignedToEntity_Whiteliste
#region GetPersonalizationAsync()
// Person
[TestCase(DistributionChannels.Email, IdTypes.Bsn, false, "-", "no")]
[TestCase(DistributionChannels.Email, IdTypes.Bsn, true, "2024-07-24", "yes")]
[TestCase(DistributionChannels.Email, IdTypes.Bsn, true, "24-07-2024", "yes")]
[TestCase(DistributionChannels.Sms, IdTypes.Bsn, false, "-", "no")]
[TestCase(DistributionChannels.Sms, IdTypes.Bsn, true, "2024-07-24", "yes")]
[TestCase(DistributionChannels.Sms, IdTypes.Bsn, true, "24-07-2024", "yes")]
// Organization
[TestCase(DistributionChannels.Email, IdTypes.Kvk, false, "-", "no")]
[TestCase(DistributionChannels.Email, IdTypes.Kvk, true, "2024-07-24", "yes")]
[TestCase(DistributionChannels.Email, IdTypes.Kvk, true, "24-07-2024", "yes")]
[TestCase(DistributionChannels.Sms, IdTypes.Kvk, false, "-", "no")]
[TestCase(DistributionChannels.Sms, IdTypes.Kvk, true, "2024-07-24", "yes")]
[TestCase(DistributionChannels.Sms, IdTypes.Kvk, true, "24-07-2024", "yes")]
public async Task GetPersonalizationAsync_SpecificDateTime_ReturnsExpectedPersonalization(
DistributionChannels testDistributionChannel, IdTypes idType, bool isExpirationDateGiven, string testExpirationDate, string isExpirationDateGivenText)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// © 2024, Worth Systems.

using EventsHandler.Constants;
using EventsHandler.Extensions;
using EventsHandler.Mapping.Enums.NotificatieApi;
using EventsHandler.Mapping.Enums.Objecten;
using EventsHandler.Mapping.Enums.Objecten.vNijmegen;
Expand Down Expand Up @@ -608,7 +609,7 @@ public void Serialize_TaskObject_Hague_Default_ReturnsExpectedJson(bool isDefaul
$"\"zaak\":\"{DefaultValues.Models.EmptyUri}\"," +
$"\"title\":\"\"," +
$"\"status\":\"-\"," +
$"\"verloopdatum\":\"{DateTime.MinValue:O}\"," +
$"\"verloopdatum\":\"{DateTime.MinValue.ConvertToDutchDateString()}\"," +
$"\"identificatie\":{{" +
$"\"type\":\"-\"," +
$"\"value\":\"\"" +
Expand Down Expand Up @@ -638,7 +639,7 @@ public void Serialize_TaskObject_Nijmegen_Default_ReturnsExpectedJson(bool isDef
$"\"uuid\":\"{Guid.Empty}\"," +
$"\"registratie\":\"-\"" +
$"}}," +
$"\"verloopdatum\":\"{DateTime.MinValue:O}\"," +
$"\"verloopdatum\":\"{DateTime.MinValue.ConvertToDutchDateString()}\"," +
$"\"identificatie\":{{" +
$"\"type\":\"-\"," +
$"\"value\":\"\"" +
Expand Down Expand Up @@ -684,7 +685,7 @@ public void Serialize_TaskObject_Hague_ValidModel_ReturnsExpectedJson()
$"\"zaak\":\"{TestUrl}\"," +
$"\"title\":\"{TestString}\"," +
$"\"status\":\"open\"," +
$"\"verloopdatum\":\"2024-09-05T15:45:30.0000000Z\"," +
$"\"verloopdatum\":\"05-09-2024\"," +
$"\"identificatie\":{{" +
$"\"type\":\"bsn\"," +
$"\"value\":\"{TestString}\"" +
Expand Down Expand Up @@ -737,7 +738,7 @@ public void Serialize_TaskObject_Nijmegen_ValidModel_ReturnsExpectedJson()
$"\"uuid\":\"{Guid.Empty}\"," +
$"\"registratie\":\"zaak\"" +
$"}}," +
$"\"verloopdatum\":\"2024-09-05T15:45:30.0000000Z\"," +
$"\"verloopdatum\":\"05-09-2024\"," +
$"\"identificatie\":{{" +
$"\"type\":\"bsn\"," +
$"\"value\":\"{TestString}\"" +
Expand Down Expand Up @@ -839,7 +840,7 @@ public void Serialize_CommonTaskData_ReturnsExpectedJson()
$"\"CaseId\":\"{testGuid}\"," +
$"\"Title\":\"text\"," +
$"\"Status\":\"open\"," +
$"\"ExpirationDate\":\"9999-12-31T23:59:59.9999999\"," +
$"\"ExpirationDate\":\"31-12-9999\"," +
$"\"Identification\":{{" +
$"\"type\":\"bsn\"," +
$"\"value\":\"123456789\"" +
Expand Down

0 comments on commit 246d23d

Please sign in to comment.