News for hackers. Stuff that matters.
Re:Do not use 'week year': YYYY by lloydatkinson on Tuesday January 04, 2022 @08:42AM (#29794581)
100% agreed with you. I do not understand why stringly typed date systems are still so prevalent.

When I write code that needs to format in different formats I always create well named, perhaps verbose but I don't care as it's now readable, functions such as this (ignore HN butchering the code):

    /\*
     \* Formats Date into "twelve hour time". For example, 3:23. This is "h:mm" format from date-fns.
     \* @param { Date } date The date.
     \* @returns { string } The formatted string.
     \*/
     export const formatAsTwelveHourTime = (date: Date) => format(date, 'h:mm');

There are no comments on this comment yet.