@saxnpaule said in New plugin [pimatic-datetime]:
He wants to know if it is weekend. I think I will add this too.
Most Google / StackOverflow hits are suggesting to use either the result of Date.getDay()
or moment.weekDay()
and regard 0
and 6
as weekend. That’s poor, however, as it does not take into account that the first weekday can differ depending on the locale set. Thus it is better to use the following:
isWeekend: () ->
moment.isoWeekday() > 5
EDIT: This may look wrong at a first glance. However, bear in mind that the isoWeekday() result ranges from 1
to 7
.
"It always takes longer than you expect, even when you take into account Hofstadter's Law.", Hofstadter's Law