Date Calculations

D

Dr John Stockton

I have been, and am still, working on improving Week Number programming,
now in <URL:http://www.merlyn.demon.co.uk/weekcalc.htm>.

I have added three parameterised functions each giving non-standard
(i.e. suitable for the USA) output [Y W D] for a Date Object, and their
reverses, for
Type 1. Year Number is Calendar Year, so partial weeks are required.
Type 2. Every Week has Seven Days, so the Year Number can differ from
the Calendar Year. ISO Week Numbers are a specific case.
Type 3. Week 01 begins on a Given Date.
Please tell me of any extant sort of Week Number which is not
accommodated by those.

(That general Type 2 code is *not* optimal for ISO Week Number)


I have noted that a routine using UTC methods is much faster than a
similar routine using local methods, and have made a couple of other
routines much faster by converting them from local to UTC internally.

Probably UTC is faster because there is no need to consult, repeatedly,
the Summer Time Rules.

NOTE that much common javascript date work does not *need* local date;
for example, much calendar work can be done in UTC. The present
date/time can easily be converted into a UTC date by applying
getTimezoneOffset. The reverse takes a little more thought, for the
worst case Summer Time rules, unless the obvious brute-force method is
used.


Also, using a routine found in 'The Calendar FAQ' and another derived
from the work of Zeller, ISO 8601 Y W D can be obtained by going via
CMJD, a standard daycount - and vice versa. That's about as fast as he
best of the rest, in my MSIE4.


The names of some of my javascript functions have changed.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,781
Messages
2,569,619
Members
45,316
Latest member
naturesElixirCBDGummies

Latest Threads

Top