LunchDevCommunity / community-calendar

📅 Community calendar for our Discord server, built with love and Eleventy.
https://events.lunch.dev
15 stars 12 forks source link

localize event dates #71

Closed chantastic closed 3 years ago

chantastic commented 3 years ago

we've batted this idea around a couple times in Discord but haven't prioritized it yet.

the idea is to provide dates in UTC and progressively enhance them with a localized date.

in the abstract, here's some ideas that have been mention and i've batted around:

Markup

<time datetime="1914-12-20T08:00">

JS

* get all `datetime` on page: document.querySelectorAll('[datetime]')
* replace node children with `new Date(elementDatetimeUTCDate).toLocaleString('en-US', options);`

Approach

I don't think we have to get fancy. This script could be added in src/js and linked with a <script async> tag in the templates that need it.

Note, we'll need to add a addPassthroughCopy to .eleventy.js: https://github.com/LunchDevCommunity/community-calendar/blob/main/.eleventy.js#L49-L51

I think this would be a totally decent first step toward this goal.

/cc @rstacruz @BenDMyers @msutkowski

BenDMyers commented 3 years ago

Resolved by #101