El martes, 4 de febrero de 2014 13:45:09 UTC+1, Stephan Hradek escribió:
>
>
>
> date is the first of the month.
> DayNamesShort.length is 7 as there are 7 days in the week
> date.getDay gives the weekday, a number from 0 to 6
> FirstDayOfWeek is the weekday of the day which you want to be the first 
> day of the week, so also 0-6
>
> The calculation simply finds the beginning of the week of the first of the 
> month.
>

I already realized about the Value of the variables, but at the beginning I 
didn't understand the logic. After a more exhaustive breakdown and reading 
the Date object documentation further I understood it.
As you said that line sets the date to the first day of the first week of 
that month, which in many cases is part of the past month. That confused me 
at a first instance. After that, you only print the day value if the month 
where you are is the desired month. In any case you print the cell and 
advance to the next day. This way you don't have to worry about exceptions 
of weird days, months starting at Sunday and so on. It even works if 
somebody changes the order of the days. Making all the calculations 
relative to the first day of the week you can configure it however you 
want. 
Please let me say your implementation is elegant and brilliant. 
  

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To post to this group, send email to tiddlywiki@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to