[Tutor] how to get the weeks of a month

David Rock david at graniteweb.com
Mon Mar 4 16:35:56 EST 2019


> On Mar 4, 2019, at 15:28, john fabiani <johnf at jfcomputer.com> wrote:
> 
> I knew there was a simple why to get it done!  But where is it off my a day?
> 

comparing

$ cal
     March 2019
Su Mo Tu We Th Fr Sa
                1  2
 3  4  5  6  7  8  9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31

to

import calendar as cal
cal.monthcalendar(2019,3)
[[0, 0, 0, 0, 1, 2, 3], [4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16,
17], [18, 19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30, 31]]

I see the first element of the array is
[0, 0, 0, 0, 1, 2, 3]

where I would have expected
[0, 0, 0, 0, 0, 1, 2]

Which I’m sure is just a question of “defining the start of the week” properly, but if you just took it as-is, Mar 1 would be Thursday, not Friday if you translated literally.


— 
David Rock
david at graniteweb.com






More information about the Tutor mailing list