You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is just me venting, but this is the typescript code for EDTF parsing AND localized date-time formatting, and one or two of the lines are unnecessary.
formatDate(date: string,options: Intl.DateTimeFormatOptions): string {constparsedDate=edtf.default(date);constyear=parsedDate.year.toString();constoptKeys=Object.keys(options);constuseYear=optKeys.includes("year")&&optKeys.length===1;constformattedDate=useYear
? year
: edtf.format(parsedDate,"en-US",options);// yeah, the locale is fixed here, but easy to generalizereturnformattedDate;}
Doing something equivalent in Rust with existing crates is basically impossible, and a huge hassle. Why?
I suppose ideally I'd fork edtf.rs and modify it so it's better suited for cases like this, which often don't have complete dates.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
This is just me venting, but this is the typescript code for EDTF parsing AND localized date-time formatting, and one or two of the lines are unnecessary.
Doing something equivalent in Rust with existing crates is basically impossible, and a huge hassle. Why?
I suppose ideally I'd fork edtf.rs and modify it so it's better suited for cases like this, which often don't have complete dates.
Beta Was this translation helpful? Give feedback.
All reactions