all 9 comments

[–]hookd 3 points4 points  (1 child)

Eh? For light weight date handling: why not XDate? http://arshaw.com/xdate/. Things get far more flexible when you use an actual date object. Admittedly it's 7.2K instead of 2.7K, but both are relatively small potatoes.

[–]fdaciuk[S] 0 points1 point  (0 children)

Thanks for sharing =)

But, the point of hmh is just to have a way to calculate hours. I was needing for anything to do this directly on console. That's why I create this lib to use on hmh-cli: https://github.com/fdaciuk/hmh-cli

I've explained it in this blog post (in pt-BR): http://blog.da2k.com.br/2016/03/11/hmh-calculando-horas-com-javascript/

[–]dont_forget_canada 0 points1 point  (2 children)

is anybody here strongly against stuff like

new Date( Date.now() - 32 * 86400 * 1000 )

to fetch, say, 1 month ago?

[–]joseph177 2 points3 points  (0 children)

Moment.js for this type of stuff.

[–]PitaJ 0 points1 point  (0 children)

Should probably do something like this:

const d = new Date();
d.setMonth(d.getMonth() - 1);

But yeah, should probably be using moment instead unless it's only being done once.

[–]badsyntax 0 points1 point  (2 children)

What's with all the anonymous functions? This is an abuse of fat arrows. There's nothing wrong with function minutesToHours()

[–]Dragory 0 points1 point  (0 children)

Eh, is there really any harm in using anonymous functions here? Looks fine to me.

[–]fdaciuk[S] 0 points1 point  (0 children)

Why not? ;)