Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
I use moment.js and having no issue making it work with a .net service in terms of formatting date for .net to understand. Though I'm not JS expert just a noob finding his way lol
-
kurtr126527y@gitpush Yeah I've used moment and a few others. What pisses me off is time like now when I just need to display some thing like the current date once and don't want to import a whole library so I end up writing a 15 line function for it. Getting a date like 1st July 2017 is fucking insanely difficult. I wish js had php's date style i.e. date('Y-m-d')
-
@kurtr aah I see your point, yes this is just fked up. I guess JS is not dev friendly :S
-
Watch the video about internationalizing code or timezone madness by computerphile and you will probably understand...
-
yusijs12507yIt's really not that hard:
let d = new Date();
let monthLookup = ['January', 'February'.....]
let formatted = `${d.getDay()}st ${monthLookup[d.getMonth()]}, ${d.getFullYear()}`;
Verbose - yes.
Hard - not really.
¯\_(ツ)_/¯
P.s @gitpush: use date-fns over moment. Moment is hilariously big (hundreds of kb minified). -
yusijs12507y@gitpush np! I usually start off with moment (habits etc), but noticed with the stats-output from webpack that it adds a tremendous amount of redundant code. If you use a shitton of it then that's fine, but normally I use maybe 3-4 functions. Adding such a huge library seems silly when there are alternatives :)
-
@yusijs yup but coming from .Net with our spoiled datetime class moment looks easiest for now, though gotta learn alternatives 😀
-
yusijs12507y@kurtr true, but wouldnt be to hard to implement. Not to many checks:
1st, 21st, 31st
2nd, 22nd
3rd, 23rd
4th-20th, 24th-30th
May have missed a case here and there but eh.
Again - verbose, yes. Not hard though. -
yusijs12507y@gitpush yeah I know, I love the simplicity in Go as well. Formatting dates is a breeze.
-
yusijs12507y@gitpush mate that's a rule of life. Javascript is amazing. It's like riding a bike. Except the bike is on fire and you're on fire and everything is on fire and you're in hell.
Related Rants
I want to stab the person that decided to make dates in JavaScript so fucking complicated to format.
undefined
js
why??
dates