In Europe ISO 8601 week numbers are used for many planning and accounting
purposes. I have created code for adding week numbers on the calendar. If
any committer is interested, I can email the complete code. I have also
written code for including week number on the clock, but the difficulty in
including literal strings in the clock code makes this almost useless.
Hope this code can be useful for someone else as well.
Thanks,
~Johannes
Here are the diffs:
In calendar.js
194,201d193
<
< function display_weeknum(date)
< {
< return getWeekNumber(new Date(date.getYear(), date.getMonth(),
date.getDate()+(2-WEEK_START_DAY)));
< }
<
<
<
302,305d293
< //print week number
< if ( calendarShowWeek )
< cal += day_start + "Week" + day_end;
<
338c326
< if (week_day == WEEK_START_DAY - 1) {
---
> if (week_day == WEEK_START_DAY - 1) dayString += TR_end + TR_start;
339,344d326
< dayString += TR_end + TR_start;
<
< if ( calendarShowWeek )
< dayString += gray_start(display_weeknum(Calendar)) +
display_weeknum(Calendar) + TD_end;
< }
<
In strings.js
194a195,222
>
>
>
> // Julian date is defined as the day of the year (1-366)
> function getJulianDate(date)
> {
> var MILLIS_PER_DAY = 24*60*60*1000;
>
> var newYearDay = new Date(date.getYear(), 0, 1);
> return Math.ceil((date.getTime()-newYearDay.getTime())/MILLIS_PER_DAY) +
1;
> }
>
> // ISO 8601 Weekday:
> // Week starts on monday
> // Week 1 is first week with 4 days, i.e. first week with a thursday
> function getWeekNumber(date)
> {
> var THURSDAY = 4;
>
> // Lemma 1: Weeknum of a thursday is always in correct year
> // we call this thursday "determinant_day"
>
> var determinant_day = new Date(date.getYear(), date.getMonth(),
date.getDate() );
> determinant_day.setDate(determinant_day.getDate() -
determinant_day.getDay() + THURSDAY);
>
>
> return Math.ceil(getJulianDate(determinant_day)/7);
> }
In preferences.js
182a183,184
> /* Show ISO 8601 week number in calendar? */
> calendarShowWeek = false;
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
DQSD-Devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dqsd-devel