Re: [csswg-drafts] [css-values] Time based numerical functions (#13659)

> Why would these be functions instead of environment variables accessible by `env()`?

I think that would prevent us from specifying time relative to a specific time zone or calendar. 
```css
--background-index: mod(day-of-year("Europe/Brussels"), 3);
```

> Could a single function like `current(<CLDR-datetime>)` be more useful? Why would I ever want to style depending on any date and time other than _now_?

I'm not sure I quite understand. 
This proposal is for numeric functions for use in computed theming / layout. We need specific functions depending on whether we want to use day-of-year or week-of-year or month in our calculations. 

I think most _conditional styling_ is better solved with a _conditional time query_ like you proposed in  https://github.com/w3c/csswg-drafts/issues/9710. Something like `@media time(2023-11-20 <= current <= 2023-11-26)`. Let's discuss that over there :)

I'll edit my proposal text to make it more clear that this is for use in computations (and not conditional css) i.e. calculating a theme color based on the numeric value returned from the function (or keyword).

> How do you get the current month number of, for instance, the Hebrew, Islamic or Coptic calendar?
>
> What would the function for the day of the week (DOW) return today, i.e. on a Sunday? Does it differ if I was from (or in) the US or Afghanistan instead of Europe?
>
> Which number does the year function return when my browser/OS locale is set to Thailand, Japan, Ethiopia or Iran?

I think it should be aligned with the corresponding Temporal property: 

month:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Temporal/ZonedDateTime/month
https://tc39.es/proposal-temporal/docs/zoneddatetime.html#month

dayOfWeek:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Temporal/ZonedDateTime/dayOfWeek

year:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Temporal/ZonedDateTime/year

> How do I use these functions to style something for Lent, Orthodox Easter, Ramadan, US Thanksgiving, Chinese New Year, Pisces or Mother’s Day?

They are not designed to solve that problem. I think conditional time queries could be better suited for that. Let's discuss over in https://github.com/w3c/csswg-drafts/issues/9710.

> Does the day function always change its result at local midnight or can I get it to switch at dusk, nightfall, sunset (at a specific place), 06:00 or noon? 

Maybe the functions could accept an hourly offset like `day-of-year(+8)`? It would be possible to use another timezone, but then different daylight saving times might apply.





-- 
GitHub Notification of comment by johannesodland
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/13659#issuecomment-4070395550 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Monday, 16 March 2026 20:26:15 UTC