[<<]Message[>>]    [<<]Author[>>]    [<<]Subject[>>]    [<<]Thread[>>]

Number : 4440 Date : 2003-04-24 Author : Kan Yabumoto Subject : Re: Date Macro Size(KB) : 4
Garry wrote: >You could even go the whole hog and include ISO Week No ($WW$ or >$WK$?) so someone could create the alternate date format in the form >2003-W14-2 (yyyy-Wweekno-dayofweek). Although the following is a bit >clumsy it is feasible. > >/$yyyy$-W/$ww-w$ That's interesting. I could do that. I would use /$KK$ rather than /$WW$ (see below for why). Also, for the convenience of adding the prefix, W to easily conform to the ISO 8601 standard, we can define /$WKK$ specifically for that. So, /$KK$ will expand to a value like 17 and /$WKK$ expands to W17. Therefore, Garry's "clumsy" notation will be cleaned up; /$yyyy-wkk-k$ (See below for the single /$K$) I was not aware that the ISO standard assigns the radix value of 7 for Sunday. That seems contrary to my sense of tradition that most people consider Sunday as the beginning of the week. Look at Window's Date and Time display. The calendar clearly shows Sunday to the left which is the most common calendar I've seen. Apparently, ISO treats a week as starting on Monday and ending on Sunday. The ISO web page does not tell it explicitly. http://www.iso.ch/iso/en/prods-services/popstds/datesandtime.html But, from its context, it is reasonable to interpret that ISO defines that a week starts on Monday. It is easy for me to convert the Sunday value for /$W$ to 7 rather than 0. But that would break existing user's batch file. Besides, it will not allow concatenation of W17 notation with the single digit radix value of the day of the week. So, We could assign a new mnemonic to the ISO-way of the day-of-the-week radix value using /$K$ -------------------------------------------------------- The current /$W$ scheme (Sun:0 - Sat:6) was not rally an arbitrary choice. It has been done and can be considered an established convention if not a standard. -------------------------------------------------------- So, if you say /$yyyy-wkk-k$, it will be expanded to 2003-W17-4 // 4th day of Week 17 of 2003 == 2003-04-24 And, you can say /$yyyywkkk$ which expands to 2003W174 (Since the /$KK$ notation always uses a 2-digit value (with a leading zero when needed) and the /$K$ value is always a single digit, no ambiguity there. Here, some careful reader may notice that we have been keeping the macro keywords to exactly match the length of the expanded string. All of the newly proposed macro keywords here remain true to this rule. Alas, the variable-length /$m$, /$d$, /$h$, /$n$ and /$s$ that started all this discussion broke this rule which was another reason for my grumble for that. Well, some stubborn people may insist on a version without the leading zero for the /$KK value --- they should be sent to the Guantanamo Bay camp and learn the Koran first. ----------------------------------------------------------- You may ask "why not /$WW$ instead of /$KK$ ?". We chose /$WWW$ for day-of-the-week and /$W$ also for day-of-the-week in radix -- they are both representing the same thing in different formats. But, the week-of-the-year is a different concept and using /$WW$ would somehow break the symmetry. Besides, this notation would be most convenient when the week-of-the-year and numeric day-of-the-week are specified side-by-side without break. Considering the precedence rule (the longest keyword matches first), assigning /$KK$ seems more convenient than /$WW$. It is unfortunate that we had /$W$ that turned out to be non-ISO (and /$KK$ and /$K$ are not symmetrical). ----------------------------------------------------------- One benefit of treating Monday as the first day of the week is that Saturday and Sunday can be more easily treated as a contiguous entity --- I guess this has more benefit to nearly everyone even though most calendars we encounter will likely to continue with Sunday at the left most column. Well, figuring the week-of-the-year value will be a bit of a pain to program. But, it should not be too bad (XXCOPY already knows how to convert a date to the day-of-the-week and also knows the leap-year rules). Kan Yabumoto
This message if part of XXCOPY's message Archive. The archive contains all the messages posted at Yahoo!Groups: XXCOPY.