Skip to content

Commit

Permalink
format_date fix
Browse files Browse the repository at this point in the history
  • Loading branch information
heyajohnny committed Sep 13, 2024
1 parent b877081 commit 942cfde
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
3 changes: 2 additions & 1 deletion Version
Original file line number Diff line number Diff line change
Expand Up @@ -200,4 +200,5 @@ version: 2.0.8 20231217 - Use friendly name of other sensors in the today and t
version: 2.1.0 20240428 - Update existing sensor is now available (so you don't need to delete and re-add it)
version: 2.1.1 20240603 - Possible fix for ConfigFlowResults error
version: 2.1.2 20240713 - Fix config entry setup warning
version: 2.1.3 20240718 - http -> https
version: 2.1.3 20240718 - http -> https
version: 2.1.4 20240913 - format_date fix
8 changes: 6 additions & 2 deletions custom_components/afvalinfo/hacs.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
"name": "Afvalinfo",
"content_in_root": false,
"render_readme": true,
"domains": ["sensor"],
"country": ["NL"],
"domains": [
"sensor"
],
"country": [
"NL"
],
"homeassistant": "0.100.0"
}
2 changes: 1 addition & 1 deletion custom_components/afvalinfo/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"domain": "afvalinfo",
"name": "Afvalinfo",
"version": "2.1.3",
"version": "2.1.4",
"config_flow": true,
"iot_class": "cloud_polling",
"documentation": "https://github.com/heyajohnny/afvalinfo",
Expand Down
10 changes: 8 additions & 2 deletions custom_components/afvalinfo/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback

async def async_format_date(hass, collection_date, half_babel_half_date, locale):
return await hass.async_add_executor_job(
format_date, collection_date, half_babel_half_date, locale
)

async def async_setup_entry(
hass: HomeAssistant,
config_entry: config_entries.ConfigEntry,
Expand Down Expand Up @@ -366,10 +371,11 @@ async def async_update(self):
r"(\d+)", r"'\1'", half_babel_half_date
)
# transform the EEE, EEEE etc... to a real locale date, with babel
locale_date = format_date(
locale_date = await async_format_date(
self.hass,
collection_date,
half_babel_half_date,
locale=self.locale,
self.locale,
)

self._state = locale_date
Expand Down

0 comments on commit 942cfde

Please sign in to comment.