Skip to content

Commit

Permalink
fix: use static format infos
Browse files Browse the repository at this point in the history
  • Loading branch information
Dim145 committed May 29, 2024
1 parent 46e9fad commit 0921a63
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 5 deletions.
9 changes: 9 additions & 0 deletions Hariane/ApiClient.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Globalization;
using System.Net;
using System.Text.Json;
using HtmlAgilityPack;
Expand All @@ -13,6 +14,14 @@ public class ApiClient
public const int maxDays = 17;
public const string dateFormat = "dd/MM/yyyy";

public static DateTimeFormatInfo FormatInfo { get; } = new()
{
ShortDatePattern = "dd/MM/yyyy",
ShortTimePattern = "HH:mm:ss",
LongDatePattern = "dd/MM/yyyy HH:mm:ss",
LongTimePattern = "HH:mm:ss",
};

private HttpClient Client { get; }

private string Username { get; set; }
Expand Down
4 changes: 2 additions & 2 deletions Hariane/LastIndex.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ public class LastIndex

public DateTime GetEndDateJour()
{
return DateTime.Parse(EndDateJour, CultureInfo.GetCultureInfoByIetfLanguageTag("fr-FR"));
return DateTime.Parse(EndDateJour, ApiClient.FormatInfo);
}

public DateTime GetStartDateJour()
{
return DateTime.Parse(StartDateJour, CultureInfo.GetCultureInfoByIetfLanguageTag("fr-FR"));
return DateTime.Parse(StartDateJour, ApiClient.FormatInfo);
}
}
2 changes: 1 addition & 1 deletion Hariane/VisuConso.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public Dictionary<DateTime, float> GetConso()
var dateStr = line[0]?.ToString();
var valueStr = line[1]?.ToString();

res.Add(DateTime.Parse(dateStr.Split(" ").Last(), CultureInfo.GetCultureInfoByIetfLanguageTag("fr-FR")), float.Parse(valueStr, CultureInfo.InvariantCulture));
res.Add(DateTime.Parse(dateStr.Split(" ").Last(), ApiClient.FormatInfo), float.Parse(valueStr, CultureInfo.InvariantCulture));
}
catch (Exception e)
{
Expand Down
2 changes: 1 addition & 1 deletion addon/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ CMD ["/entrypoint.sh"]
############

LABEL \
io.hass.version="0.1.4" \
io.hass.version="0.1.5" \
io.hass.type="addon" \
io.hass.arch="armv7|amd64|arm64"
2 changes: 1 addition & 1 deletion addon/config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: "Hariane 2 MQTT"
description: "Extracts Hariane water data into MQTT a.o."
version: 0.1.4
version: 0.1.5
slug: "hariane_2_mqtt"
url: https://github.com/Dim145/Hariane2Mqtt
init: true
Expand Down

0 comments on commit 0921a63

Please sign in to comment.