Why does the time package only define durations up to Hour?
from GarytheSnail@programming.dev to golang@programming.dev on 17 Jan 2024 19:22
https://programming.dev/post/8729617

I am doing a lot of work right now that requires day and year durations and I have to define those myself. I wonder why they didn’t include those in the time package.

#golang

threaded - newest

tedu on 17 Jan 2024 19:35 collapse

If they provided constants, someone would complain that they produce the wrong result for daylight savings or leap years.

iluminae@lemmy.world on 17 Jan 2024 20:46 collapse

This - no one can agree how long a day, week, month, year etc are!

Like sure it’s 24 hours in a day but is a year 365 days? No, not technically speaking.

Time has always been really hard for programmers.

GarytheSnail@programming.dev on 17 Jan 2024 22:26 collapse

Well now I need to go add some tests and fix some bugs. Thanks yall.