Skip to content

Commit

Permalink
Merge pull request #27 from BRP-API/chore/sync-met-source-repo_d9b81a6
Browse files Browse the repository at this point in the history
sync met 'BRP-API/brp-shared-dotnet' repo
  • Loading branch information
MelvLee authored Nov 28, 2024
2 parents 8eeaaee + cfaaec1 commit b0c3b34
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 37 deletions.
4 changes: 0 additions & 4 deletions src/Brp.Shared.DtoMappers/Brp.Shared.DtoMappers.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<Folder Include="BrpApiDtos\" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="AutoMapper" Version="13.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
Expand Down
64 changes: 32 additions & 32 deletions src/Brp.Shared.DtoMappers/Mappers/DatumMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,21 @@ namespace Brp.Shared.DtoMappers.Mappers;
public static class DatumMapper
{
private static readonly Regex GbaDatumRegex = new("^(?<jaar>[0-9]{4})(?<maand>[0-9]{2})(?<dag>[0-9]{2})$", RegexOptions.None, TimeSpan.FromMilliseconds(100));
private static readonly Dictionary<int, string> MaandDictionary = new ()
{
{1, "januari" },
{2, "februari" },
{3, "maart" },
{4, "april" },
{5, "mei" },
{6, "juni" },
{7, "juli" },
{8, "augustus" },
{9, "september" },
{10, "oktober" },
{11, "november" },
{12, "december" }
};

public static AbstractDatum Map(this string datum)
{
Expand All @@ -20,52 +35,37 @@ public static AbstractDatum Map(this string datum)
AbstractDatum retval = new DatumOnbekend();
if (jaar != 0 && maand != 0 && dag != 0)
{
retval = new VolledigeDatum() { Datum = new DateTime(jaar, maand, dag) };
retval = new VolledigeDatum()
{
Datum = new DateTime(jaar, maand, dag, 0, 0, 0, DateTimeKind.Local),
LangFormaat = $"{dag} {MaandDictionary[maand]} {jaar}"
};
}
if (jaar != 0 && maand != 0 && dag == 0)
{
retval = new JaarMaandDatum() { Jaar = jaar, Maand = maand };
retval = new JaarMaandDatum()
{
Jaar = jaar,
Maand = maand,
LangFormaat = $"{MaandDictionary[maand]} {jaar}"
};
}
if (jaar != 0 && maand == 0 && dag == 0)
{
retval = new JaarDatum { Jaar = jaar };
retval = new JaarDatum
{
Jaar = jaar,
LangFormaat = $"{jaar}"
};
}

retval.LangFormaat = retval.LangFormaat();
return retval;

}

return new DatumOnbekend
{
LangFormaat = "onbekend"
};
}

public static string? LangFormaat(this AbstractDatum datum)
{
var maand = new Dictionary<int, string>
{
{1, "januari" },
{2, "februari" },
{3, "maart" },
{4, "april" },
{5, "mei" },
{6, "juni" },
{7, "juli" },
{8, "augustus" },
{9, "september" },
{10, "oktober" },
{11, "november" },
{12, "december" }
};

return datum switch
{
VolledigeDatum d => $"{d.Datum!.Value.Day} {maand[d.Datum!.Value.Month]} {d.Datum!.Value.Year}",
JaarMaandDatum d => $"{maand[d.Maand!.Value]} {d.Jaar}",
JaarDatum d => $"{d.Jaar}",
DatumOnbekend => "onbekend",
_ => null
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<PackageReference Include="AspNetCore.HealthChecks.Uris" Version="8.0.1" />
<PackageReference Include="Destructurama.Attributed" Version="4.0.0" />
<PackageReference Include="Destructurama.JsonNet" Version="3.0.0" />
<PackageReference Include="Elastic.Serilog.Enrichers.Web" Version="8.12.2" />
<PackageReference Include="Elastic.Serilog.Enrichers.Web" Version="8.12.3" />
<PackageReference Include="FluentValidation" Version="11.11.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.36" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
Expand Down

0 comments on commit b0c3b34

Please sign in to comment.