trilobite
August 24th, 2007, 09:36 AM
Hi all -
I'm wanting to do a simple text-based calendar app in Python (it'll be public-domain). ( Btw, I'm running Feisty, with Python 2.5.1).
I've done a bit of "background thinking" on this, as follows -
*** Start of "background notes" ***
Any month can be described with a 3-digit code, where the first two digits are the number of days in the month (28-31), and the last digit is the day of the week that the month starts on.
So, Jan 2007 is shown by 312 - 31 day, starts on Monday (2).
( I'll use 1 for Sunday, through to 7 for Saturday).
So, the month-structure of 2007 is as follows -
Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec
312, 285, 315, 301, 313, 306, 311, 314, 307, 312, 305, 317.
2008 will be as follows -
Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec
313, 296, 317, 303, 315, 301, 313, 316, 302, 314, 307, 312.
We can use "clock arithmetic" (also called "modulo arithmetic") to change the weekdays from year to year.
A "clock" with 7 "hours", representing the days of the week. will be used. This could be done with a "circular list".
*** End of background notes ***
I've already found some very-useful p.d. Python code for doing tables. Now, I just need to do the circular lists and go from there, then merge that code with the table code. However, I've got a bit of a "mental block" as to how to do a circular list.
A good "test-case" is Dec this year (which is a "317") which will then be a "312" next year (as it starts on a Monday).
( Leap-year next year, remember.... ;-) )
So, there's a good example of the "wrap-around" that I want.
So, anyone able to help on doing circular lists? Many thanks in advance.... bye foe now -
- trilobite
I'm wanting to do a simple text-based calendar app in Python (it'll be public-domain). ( Btw, I'm running Feisty, with Python 2.5.1).
I've done a bit of "background thinking" on this, as follows -
*** Start of "background notes" ***
Any month can be described with a 3-digit code, where the first two digits are the number of days in the month (28-31), and the last digit is the day of the week that the month starts on.
So, Jan 2007 is shown by 312 - 31 day, starts on Monday (2).
( I'll use 1 for Sunday, through to 7 for Saturday).
So, the month-structure of 2007 is as follows -
Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec
312, 285, 315, 301, 313, 306, 311, 314, 307, 312, 305, 317.
2008 will be as follows -
Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec
313, 296, 317, 303, 315, 301, 313, 316, 302, 314, 307, 312.
We can use "clock arithmetic" (also called "modulo arithmetic") to change the weekdays from year to year.
A "clock" with 7 "hours", representing the days of the week. will be used. This could be done with a "circular list".
*** End of background notes ***
I've already found some very-useful p.d. Python code for doing tables. Now, I just need to do the circular lists and go from there, then merge that code with the table code. However, I've got a bit of a "mental block" as to how to do a circular list.
A good "test-case" is Dec this year (which is a "317") which will then be a "312" next year (as it starts on a Monday).
( Leap-year next year, remember.... ;-) )
So, there's a good example of the "wrap-around" that I want.
So, anyone able to help on doing circular lists? Many thanks in advance.... bye foe now -
- trilobite