SplittyDev / spacebadgers

Fast and clean SVG badges
https://badgers.space
MIT License
252 stars 4 forks source link

[feat] countdown #47

Open 1000i100 opened 3 months ago

1000i100 commented 3 months ago

I would love to be able to generate countdown like this : https://badgers.space/countdown/myLabel/2024-12-25 show a badge like this : [ myLabel | 9 months 3 days ] https://badgers.space/countdown/myLabel/2024-12-25T12:00:00Z show a badge like this : [ myLabel | 9 months 3 days ] but if less than a month, it will be [ myLabel | 3 days 9 hours ] and less than a day [ myLabel | 6 hours 35 minutes ] https://badgers.space/countdown/myLabel/2024-12-25/Md like [ myLabel | 9 months 3 days ] but will switch from [ myLabel | 1 day ] to [ myLabel | today ] then [ myLabel | ended ] without going down to hours or minute, because only M month and d day are given in pattern. https://badgers.space/countdown/myLabel/2024-12-25/M will show : [ myLabel | 9 months ] then under a month : [ myLabel | this month ] https://badgers.space/countdown/myLabel/2024-12-25/d will show : [ myLabel | 153 days ] https://badgers.space/countdown/myLabel/2024-12-25T12:00:00/1Mdhm will show : [ myLabel | 9 months ] then under a month [ myLabel | 30 days ] down to minutes, but only on time unit at a time. https://badgers.space/countdown/myLabel/2024-12-25T12:00:00/2Mdhm same than before but with to at a time (the default) : [ myLabel | 9 months 3 days ] https://badgers.space/countdown/myLabel/2024-12-25T12:00:00/2Mdhm/fr same but in french : [ myLabel | 9 mois 3 jours ]

And why not with 2 dates for event :

https://badgers.space/event-countdown/myLabel/now/past/2024-12-25T12:00:00_2025-01-01T00:00:00 will show : [ myLabel | 9 months 3 days ] before the first date, then between the to dates : [ myLabel | now ] and after : [ myLabel | past ] and if you change past in the url by finished it will show : [ myLabel | finished ]

How about it ?

SplittyDev commented 3 months ago

Hey, that certainly sounds like a useful thing to add!

I'm a bit worried about how this would actually work in the real world, though.. Since Spacebadgers can only generate SVGs, the countdown will be frozen at the time of request, which in and of itself isn't a big issue, but platforms like GitHub do their own caching on top, which means that any countdown hosted on such platforms is most likely to be stale for quite some time, which limits the practical uses quite a bit..

Additionally, I think it would be hard to tell for users that it's even a countdown in the first place, because it isn't moving:

1000i100 commented 3 months ago

Thinking with the cache limitation, i think it should be limited to date, without going down to hours and minutes.

But it still usefull in my mind.

If we really want to show the countdown part, svg can handle animation and scripting, but i don't know what part of the spec is used when svg are included with img tag.

if scripting is run from the svg, it can be static server-side and updated every second client-side