clock-weather-card
clock-weather-card copied to clipboard
How to implement Ordinal date so 1st, 2nd, 5th, 22nd etc.
Is your feature request related to a problem? Please describe.
I found some code but its creating a sensor so not sure how I would call that to override the date available by the card?
Also seem to be missing the dot for current temperature when using the full example? Describe the solution you'd like
- platform: template sensors: rhinos_next_game_date: value_template: > {%- macro ordinal(num) %} {%- set d = {1:'st',2:'nd',3:'rd'} %} {%- set num = num | int %} {%- if 10 < num % 100 <= 20 %} {{- num }}th {%- else %} {{- num }}{{ d.get(num % 10, 'th') }} {%- endif %} {%- endmacro %} {% set d = as_timestamp(strptime(state_attr('calendar.leeds_rugby', 'start_time'), '%Y-%m-%d %H:%M:%S')) | timestamp_custom('%d') %} {% set end = as_timestamp(strptime(state_attr('calendar.leeds_rugby', 'start_time'), '%Y-%m-%d %H:%M:%S')) | timestamp_custom(' %B %Y') %} {{ ordinal(d) ~ end }} friendly_name: "Date"
Describe alternatives you've considered
Could just import an already formatted data sensor
Additional context
I'm Brittish 🇬🇧 & there's nothing cooler than having something display it nicley so Friday, November 24th 2023 the closest I can find on the https://moment.github.io/luxon/#/formatting?id=table-of-tokens format is Friday November 26, 2023
type: custom:clock-weather-card
entity: weather.tomorrow_io_home_daily
sun_entity: sun.sun
temperature_sensor: sensor.1_garden_temperature
weather_icon_type: line
animated_icon: true
forecast_rows: 7
locale: en-GB
time_format: 12
date_pattern: cccc, LLLL d - yyyy
hide_today_section: false
hide_forecast_section: false
hide_clock: false
hide_date: false
hourly_forecast: true
use_browser_time: false
time_zone: europe/london
unfortunately Luxon does not support ordinal formatting https://github.com/moment/luxon/issues/118 neither does clock-weather-card support dates provided by sensors. i will consider this a feature request for clock-weather-card to accept dates from sensors