Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Here's some support for week numbers
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  11 messages - Expand all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Martin Budden  
View profile  
 More options May 1 2006, 4:41 pm
From: "Martin Budden" <mjbud...@gmail.com>
Date: Mon, 01 May 2006 13:41:22 -0700
Local: Mon, May 1 2006 4:41 pm
Subject: Here's some support for week numbers
I've implemented support for week numbers. (We use them extensively at
work for project related activity.) This allows, for example, setting
the newJournal parameters

{{{<<newJournal 'YYYY-0MM-0DD wk0WW DDD'>>}}}

to give: "2006-05-01 wk18 Monday"

Support consists of two ammendments to the core, the addition of the WW
and 0WW formats in Date.prototype.formatString, and the addition of a
Date.prototype.getWeek function. These are below, followed by some test
code.

It would be great if these could be included in the next release of
TiddlyWiki. (I originally did the newJournal support as a newJournal2
macro, but think that these additions are sufficiently general to be
included in the core.)

//{{{
// Substitute date components into a string
Date.prototype.formatString = function(template)
{
...
 template = template.replace(/ss/g,this.getSeconds());
// these are the two new formats
 template = template.replace(/0WW/g,String.zeroPad(this.getWeek(),2));
 template = template.replace(/WW/g,this.getWeek());
 return template;

}

// and here's the new function
Date.prototype.getWeek = function()
{
        var dt = new Date(this.getTime());
        var d = dt.getDay();
        if (d==0) d=7;// JavaScript 0=Sun, ISO 0=Mon
        dt.setTime(dt.getTime()+(4-d)*86400000);// shift day to Thurs of same
week to calculate weekNo
        var n = Math.floor((dt.getTime()-new
Date(dt.getFullYear(),0,1)+3600000)/86400000);
        return Math.floor(n/7)+1;
}

//}}}

// Test code follows: //

/*{{{*/
//short macro for testing Date.prototype.getWeek function.
config.macros.weekNo = {label:"weekNo",prompt:"week number"};
config.macros.weekNo.handler = function(place,macroName,params)
{
        var dt = new Date(params[0]);
        t = dt.getWeek();
        var output = "w:" + String.zeroPad(t,2) + " d:" +
config.messages.dates.days[dt.getDay()];
        wikify(output,place,null,null);

}

/*}}}*/

// Test tiddler follows: //

|!date|!expected<<br>>weekno|!calc<<br>> weekno|
| 2008/02/28 | 09 |<<weekNo 2008/02/28>> |
| 2008/02/29 | 09 |<<weekNo 2008/02/29>> |
| 2008/03/01 | 09 |<<weekNo 2008/03/01>> |
| 2008/03/07 | 10 |<<weekNo 2008/03/07>> |
| 2008/03/31 | 14 |<<weekNo 2008/03/31>> |
| 2008/04/01 | 14 |<<weekNo 2008/04/01>> |
| 2008/05/01 | 18 |<<weekNo 2008/05/01>> |
| 2008/05/29 | 22 |<<weekNo 2008/05/29>> |
| 2008/06/02 | 23 |<<weekNo 2008/06/02>> |
| 2008/06/22 | 25 |<<weekNo 2008/06/22>> |
| 2008/06/30 | 27 |<<weekNo 2008/06/30>> |
| 2008/07/01 | 27 |<<weekNo 2008/07/01>> |
| 2008/07/02 | 27 |<<weekNo 2008/07/02>> |
| 2008/07/05 | 27 |<<weekNo 2008/07/05>> |

|!date|!expected<<br>>weekno|!calc<<br>> weekno|
| 2004/02/21 | 08 |<<weekNo 2004/02/21>> |
| 2004/02/28 | 09 |<<weekNo 2004/02/28>> |
| 2004/02/29 | 09 |<<weekNo 2004/02/29>> |
| 2004/03/01 | 10 |<<weekNo 2004/03/01>> |
| 2004/03/07 | 10 |<<weekNo 2004/03/07>> |
| 2004/03/14 | 11 |<<weekNo 2004/03/14>> |
| 2004/03/21 | 12 |<<weekNo 2004/03/21>> |
| 2004/03/28 | 13 |<<weekNo 2004/03/28>> |
| 2004/03/29 | 14 |<<weekNo 2004/03/29>> |
| 2004/03/30 | 14 |<<weekNo 2004/03/30>> |
| 2004/03/31 | 14 |<<weekNo 2004/03/31>> |
| 2004/04/01 | 14 |<<weekNo 2004/04/01>> |
| 2004/05/01 | 18 |<<weekNo 2004/05/01>> |
| 2004/05/29 | 22 |<<weekNo 2004/05/29>> |
| 2004/06/02 | 23 |<<weekNo 2004/06/02>> |
| 2004/06/08 | 24 |<<weekNo 2004/06/08>> |
| 2004/06/15 | 25 |<<weekNo 2004/06/15>> |
| 2004/06/22 | 26 |<<weekNo 2004/06/22>> |
| 2004/06/30 | 27 |<<weekNo 2004/06/30>> |
| 2004/07/01 | 27 |<<weekNo 2004/07/01>> |
| 2004/07/02 | 27 |<<weekNo 2004/07/02>> |
| 2004/07/03 | 27 |<<weekNo 2004/07/03>> |
| 2004/07/04 | 27 |<<weekNo 2004/07/04>> |
| 2004/07/05 | 28 |<<weekNo 2004/07/05>> |
| 2002/05/29 | 22 |<<weekNo 2002/05/29>> |

|!date|!expected<<br>>weekno|!calc<<br>> weekno|
| 1970/01/10 | 01 |<<weekNo 1970/01/01>> |
| 2005/12/28 | 52 |<<weekNo 2005/12/28>> |
| 2005/12/29 | 52 |<<weekNo 2005/12/29>> |
| 2005/12/30 | 52 |<<weekNo 2005/12/30>> |
| 2005/12/31 | 52 |<<weekNo 2005/12/31>> |
| 2006/01/01 | 52 |<<weekNo 2006/01/01>> |
| 2006/01/02 | 01 |<<weekNo 2006/01/02>> |
| 2006/01/03 | 01 |<<weekNo 2006/01/03>> |
| 2006/01/04 | 01 |<<weekNo 2006/01/04>> |
| 2006/12/28 | 52 |<<weekNo 2006/12/28>> |
| 2006/12/29 | 52 |<<weekNo 2006/12/29>> |
| 2006/12/30 | 52 |<<weekNo 2006/12/30>> |
| 2006/12/31 | 52 |<<weekNo 2006/12/31>> |
| 2007/01/01 | 01 |<<weekNo 2007/01/01>> |
| 2007/01/02 | 01 |<<weekNo 2007/01/02>> |
| 2007/01/03 | 01 |<<weekNo 2007/01/03>> |
| 2007/01/04 | 01 |<<weekNo 2007/01/04>> |
| 2007/12/28 | 52 |<<weekNo 2007/12/28>> |
| 2007/12/29 | 52 |<<weekNo 2007/12/29>> |
| 2007/12/30 | 52 |<<weekNo 2007/12/30>> |
| 2007/12/31 | 01 |<<weekNo 2007/12/31>> |
| 2008/01/01 | 01 |<<weekNo 2008/01/01>> |
| 2008/01/02 | 01 |<<weekNo 2008/01/02>> |
| 2008/01/03 | 01 |<<weekNo 2008/01/03>> |
| 2008/01/04 | 01 |<<weekNo 2008/01/04>> |
| 2006/05/01 | 18 |<<weekNo 2006/05/01>> |
| 2005/11/30 | 48 |<<weekNo 2005/11/30>> |
| 1997/12/29 | 01 |<<weekNo 1997/12/29>> |
| 1999/01/03 | 53 |<<weekNo 1999/01/03>> |
| 1999/01/04 | 01 |<<weekNo 1999/01/04>> |
| 2000/01/02 | 52 |<<weekNo 2000/01/02>> |
| 2000/01/03 | 01 |<<weekNo 2000/01/03>> |
| 2000/12/31 | 52 |<<weekNo 2000/12/31>> |
| 2001/01/01 | 01 |<<weekNo 2001/01/01>> |
| 2001/12/30 | 52 |<<weekNo 2001/12/30>> |
| 2001/12/31 | 01 |<<weekNo 2001/12/31>> |
| 2002/12/29 | 52 |<<weekNo 2002/12/29>> |
| 2002/12/30 | 01 |<<weekNo 2002/12/30>> |
| 2003/12/28 | 52 |<<weekNo 2000/12/31>> |
| 2003/12/29 | 01 |<<weekNo 2003/12/29>> |
| 2005/01/02 | 53 |<<weekNo 2005/01/02>> |


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jeremy Ruston  
View profile  
 More options May 2 2006, 6:58 am
From: "Jeremy Ruston" <jeremy.rus...@gmail.com>
Date: Tue, 2 May 2006 11:58:19 +0100
Local: Tues, May 2 2006 6:58 am
Subject: Re: Here's some support for week numbers
Great stuff, thanks Martin. There was some debate about this a few weeks ago:

http://groups.google.com/group/TiddlyWiki/browse_thread/thread/ea3011...

I'd be interested in your take on the discussion and conclusion there.

Cheers

Jeremy

On 01/05/06, Martin Budden <mjbud...@gmail.com> wrote:

--
Jeremy Ruston
mailto:jer...@osmosoft.com
http://www.tiddlywiki.com

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Martin Budden  
View profile  
 More options May 2 2006, 2:38 pm
From: "Martin Budden" <mjbud...@gmail.com>
Date: Tue, 02 May 2006 11:38:18 -0700
Local: Tues, May 2 2006 2:38 pm
Subject: Re: Here's some support for week numbers
Jeremy,

I've just joined, and wasn't aware of the previous discussion.

As is stated in that discussion, there's an ISO standard (ISO-8601)
that defines week numbers. When week numbers are used by projects
across several companies this is universally used - after all it's no
use if the statement "we're shipping the code on Monday of week 17" is
ambiguous. Week numbers are very commonly used by European companies
(I've used them communicating with Nokia, Sony Ericsson, Philips among
others).

The standard states that:
a) weeks begin on a Monday
b) the first week in the year is the first week that has 4 or more days
in it. This is equivalent to the first week with a Thursday in it.

This means that years can have either 52 or 53 weeks, and that the 1st
of Jan can occur in week 1, 52 or 53, depending on the date of the
first Thursday in January.

My code exploits the fact that week number of a given day is the same
as the week number of the Thursday of that week, and that week 1 is the
first week with a Thursday in it. Here's the code with a bit more
commenting:

var d = dt.getDay();
// in JavaScript Sunday is day 0 (days range from 0-6)
// but for the ISO standard, Sunday is day 7 (days range from 1-7)
if (d==0) d=7;

// move the day to Thursday of the same week (the 4 is day 4, thursday)
// 86400000 is the number of milliseconds in a day
dt.setTime(dt.getTime()+(4-d)*86400000);

// calculate the number of days of the shifted day from the begining
// of the year containing that day
// (note that the day shift may have caused the year to shift)
// add an hour (3600000) to compensate for rounding errors
var n = Math.floor((dt.getTime()-new
Date(dt.getFullYear(),0,1)+3600000)/86400000);

// divide number of days by 7 to get number of weeks and add 1,
// since week numbers start at 1.
return Math.floor(n/7)+1;

I'm confident that the code complies to the standard (there's a
reasonable amount of test code).

Martin


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jeremy Ruston  
View profile  
 More options May 3 2006, 5:56 am
From: "Jeremy Ruston" <jeremy.rus...@gmail.com>
Date: Wed, 3 May 2006 10:56:33 +0100
Local: Wed, May 3 2006 5:56 am
Subject: Re: Here's some support for week numbers
Yeah, I agree that the week number code checks out, I was wondering
about the issue with having to adjust the year - the suggestion that
29-12-2005 might need to be written as 2006w01. Is that really
necessary? One could imagine implementing it by having a variant code
for the year (like "WYWY") that takes into account the week number.

Cheers

Jeremy

On 02/05/06, Martin Budden <mjbud...@gmail.com> wrote:

--
Jeremy Ruston
mailto:jer...@osmosoft.com
http://www.tiddlywiki.com

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Martin Budden  
View profile  
 More options May 3 2006, 9:38 am
From: "Martin Budden" <mjbud...@gmail.com>
Date: Wed, 03 May 2006 06:38:15 -0700
Local: Wed, May 3 2006 9:38 am
Subject: Re: Here's some support for week numbers
Good point. A variant code for the week adjusted year number is
required. I guess a two character variant for a two digit year is also
required.

Rather than using "WYWY" and "WY", I think I'll use "wYYYY" and "wYY",
treating the w as a modifier to an existing format (cf 0MM). Also "WY"
seems just that little bit too common and might come up in text (eg
WYOMING). (I thought of using YWYW and YW, but then YW  comes up in
YWCA.)

Martin
 I'll implement using "WYWY" and "WY".


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Martin Budden  
View profile  
 More options May 7 2006, 5:03 am
From: "Martin Budden" <mjbud...@gmail.com>
Date: Sun, 07 May 2006 02:03:46 -0700
Local: Sun, May 7 2006 5:03 am
Subject: Re: Here's some support for week numbers
Sorry this has taken a little while, it's been a busy week.

I've added the week adjusted year format (using wYY and wYYYY). While
doing this I extended the date formatting to allow full and abbreviated
day and month names (eg February, Feb, Thursday, Thu) and lowercase
versions (eg february, feb, thursday, thu). There seem to be quite a
few Todo and Calendar type TiddlyWikis that implement their own
abbreviated date formatting. Having these in the core will benefit
these plugins, and will also mean they get there date abbreviations
translated whenever anyone translates the core.

I've implemented this as follows:

New formats MMMM, mmmm, DDDD, dddd for full month and day names (and
lowercase forms).
New formats ddd and mmm for abbreviated month and day names (lowercase
forms)
Additional monthAbbrs and dayAbbrs arrays in config.messages.dates.

New option chkDateFormatMmmDddAsFullName (set to true as default). This
option controls whether the formats DDD and MMM represent full day and
month names, or the abbreviated forms.

Having the option set true as default means that existing TiddlyWikis
and plugins won't be changed by an upgrade. They can then can either:
i) leave the option set to true
ii) change the option to false, if they prefer (or don't mind) using
the abbreviated date format
iii) change any date formats from MMM and DDD to MMMM and DDDD and then
switch the option to false.

You may wish to change
config.macros.timeline
from {dateFormat: "DD MMM YYYY"} to {dateFormat: "DD MMM YYYY"}

and the SideBarOptions Shadow tiddler
from <<newJournal 'DD MMM YYYY'>> to <<newJournal 'DD MMM YYYY'>>

on the other hand, you may wish to and retain these as they are and so
migrate to the abreviated format.

I was just about to post this, when I saw Simon Baird's AM/PM posting!
So I have included this for completeness (and to save you doing two
updates).

The the following are included below:

A) The changes to the JavaScript Date() object
B) The configuration option chkDateFormatMmmDddAsFullName (and its
associated entry in the AdvancedOptions Shadow Tiddler)
C) The additional monthAbbrs and dayAbbrs arrays in
config.messages.dates
D) The test code
E) The tiddler that exercises the test code
F) The output from the test code

A) The changes to the JavaScript Date() object:

Date.prototype.formatString = function(template)
{
        var c = config.options.chkDateFormatMmmDddCompatibility;
        template = template.replace(/wYYYY/g,this.getYearForWeekNo());
        template =
template.replace(/wYY/g,String.zeroPad(this.getYearForWeekNo()-2000,2));
        template = template.replace(/YYYY/g,this.getFullYear());
        template =
template.replace(/YY/g,String.zeroPad(this.getFullYear()-2000,2));
        template =
template.replace(/MMMM/g,config.messages.dates.months[this.getMonth()]);
        template =
template.replace(/mmmm/g,String.toLowerCase(config.messages.dates.months[th is.getMonth()]));
        template = c ?
template.replace(/MMM/g,config.messages.dates.months[this.getMonth()])
                :
template.replace(/MMM/g,config.messages.dates.monthAbbrs[this.getMonth()]);
        template =
template.replace(/mmm/g,String.toLowerCase(config.messages.dates.monthAbbrs [this.getMonth()]));
        template =
template.replace(/0MM/g,String.zeroPad(this.getMonth()+1,2));
        template = template.replace(/MM/g,this.getMonth()+1);
        template =
template.replace(/DDDD/g,config.messages.dates.days[this.getDay()]);
        template =
template.replace(/dddd/g,String.toLowerCase(config.messages.dates.days[this .getDay()]));
        template = c ?
template.replace(/DDD/g,config.messages.dates.days[this.getDay()])
                :
template.replace(/DDD/g,config.messages.dates.dayAbbrs[this.getDay()]);
        template =
template.replace(/ddd/g,String.toLowerCase(config.messages.dates.dayAbbrs[t his.getDay()]));
        template = template.replace(/0DD/g,String.zeroPad(this.getDate(),2));
        template = template.replace(/DDth/g,this.getDate()+this.daySuffix());
        template = template.replace(/DD/g,this.getDate());
        template =
template.replace(/0hh12/g,String.zeroPad(this.getHours12(),2));
        template = template.replace(/hh12/g,this.getHours12());
        template = template.replace(/0hh/g,String.zeroPad(this.getHours(),2));
        template = template.replace(/hh/g,this.getHours());
        template =
template.replace(/0mm/g,String.zeroPad(this.getMinutes(),2));
        template = template.replace(/mm/g,this.getMinutes());
        template =
template.replace(/0ss/g,String.zeroPad(this.getSeconds(),2));
        template = template.replace(/ss/g,this.getSeconds());
        template = template.replace(/[ap]m/g,this.getAmPm().toLowerCase());
        template = template.replace(/[AP]M/g,this.getAmPm().toUpperCase());
        template = template.replace(/0WW/g,String.zeroPad(this.getWeek(),2));
        template = template.replace(/WW/g,this.getWeek());
        return template;

}

Date.prototype.getWeek = function()
{
        var dt = new Date(this.getTime());
        var d = dt.getDay();
        if (d==0) d=7;// JavaScript Sun=0, ISO Sun=7
        dt.setTime(dt.getTime()+(4-d)*86400000);// shift day to Thurs of same
week to calculate weekNo
        var n = Math.floor((dt.getTime()-new
Date(dt.getFullYear(),0,1)+3600000)/86400000);
        return Math.floor(n/7)+1;

}

Date.prototype.getYearForWeekNo = function()
{
        var dt = new Date(this.getTime());
        var d = dt.getDay();
        if (d==0) d=7;// JavaScript Sun=0, ISO Sun=7
        dt.setTime(dt.getTime()+(4-d)*86400000);// shift day to Thurs of same
week
        return dt.getFullYear();

}

Date.prototype.getHours12 = function()
{
        var h = this.getHours();
        return (h > 12 ? h-12 : ( h > 0 ? h : 12 ));

}

Date.prototype.getAmPm = function()
{
        return (this.getHours() >= 12 ? "pm" : "am");

}

B) The configuration option chkDateFormatMmmDddAsFullName:

config.options = {
...
        chkDateFormatMmmDddAsFullName: true
        };

and its associated entry in the AdvancedOptions Shadow Tiddler

<<option chkDateFormatMmmDddAsFullName>> MMM and DDD date formats give
full text (eg January Monday)\n

C) The additional monthAbbrs and dayAbbrs arrays in
config.messages.dates

config.messages = {

...
        dates: {
                months: ["January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November","December"],
                monthAbbrs:
["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],
                days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday",
"Friday", "Saturday"],
                dayAbbrs: ["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]
                }
        };

D) The test code:

//short macros for testing ExtendedDateFormatting
config.macros.testExtendedDateFormatting = {};
config.macros.testExtendedDateFormatting.handler =
function(place,macroName,params)
{
        var dt = params[1] ? new Date(params[1]) : new Date(2006,1,09,2,6,8);
        var s = dt.formatString(params[0]);
        var output = params[0] + ": " + s;
        wikify(output,place,null,null);

}

config.macros.DateFormatMmmDddAsFullName = {};
config.macros.DateFormatMmmDddAsFullName.handler =
function(place,macroName,params)
{
config.options.chkDateFormatMmmDddAsFullName=true;
}

config.macros.DateFormatMmmDddAsAbbreviation = {};
config.macros.DateFormatMmmDddAsAbbreviation.handler =
function(place,macroName,params)
{
config.options.chkDateFormatMmmDddAsFullName=false;

}

E) The tiddler that exercises the test code:

!testExtendedDateFormatting Tiddler
<<DateFormatMmmDddAsFullName>>
<<testExtendedDateFormatting "YY YYYY wYY wYYYY">>
<<testExtendedDateFormatting "YY YYYY wYY wYYYY""2003/12/29">>
<<testExtendedDateFormatting "WW 0WW">>
<<testExtendedDateFormatting "MM 0MM MMM mmm MMMM mmmm">>
<<testExtendedDateFormatting "DD 0DD DDD ddd DDDD dddd">>
<<testExtendedDateFormatting "hh 0hh">>
<<testExtendedDateFormatting "mm 0mm">>
<<testExtendedDateFormatting "ss 0ss">>
<<DateFormatMmmDddAsAbbreviation>>
<<testExtendedDateFormatting "YY YYYY wYY wYYYY">>
<<testExtendedDateFormatting "YY YYYY wYY wYYYY""2003/12/29">>
<<testExtendedDateFormatting "WW 0WW">>
<<testExtendedDateFormatting "MM 0MM MMM mmm MMMM mmmm">>
<<testExtendedDateFormatting "DD 0DD DDD ddd DDDD dddd">>
<<testExtendedDateFormatting "hh 0hh">>
<<testExtendedDateFormatting "mm 0mm">>
<<testExtendedDateFormatting "ss 0ss">>
<<DateFormatMmmDddAsFullName>>
!!Output should be:
YY YYYY wYY wYYYY: 06 2006 06 2006
YY YYYY wYY wYYYY: 03 2003 04 2004
WW 0WW: 6 06
MM 0MM MMM mmm MMMM mmmm: 2 02 February feb February february
DD 0DD DDD ddd DDDD dddd: 9 09 Thursday thu Thursday thursday
hh 0hh: 2 02
mm 0mm: 6 06
ss 0ss: 8 08

YY YYYY wYY wYYYY: 06 2006 06 2006
YY YYYY wYY wYYYY: 03 2003 04 2004
WW 0WW: 6 06
MM 0MM MMM mmm MMMM mmmm: 2 02 Feb feb February february
DD 0DD DDD ddd DDDD dddd: 9 09 Thu thu Thursday thursday
hh 0hh: 2 02
mm 0mm: 6 06
ss 0ss: 8 08

F) The output from the test code:

testExtendedDateFormatting Tiddler

YY YYYY wYY wYYYY: 06 2006 06 2006
YY YYYY wYY wYYYY: 03 2003 04 2004
WW 0WW: 6 06
MM 0MM MMM mmm MMMM mmmm: 2 02 February feb February february
DD 0DD DDD ddd DDDD dddd: 9 09 Thursday thu Thursday thursday
hh 0hh: 2 02
mm 0mm: 6 06
ss 0ss: 8 08

YY YYYY wYY wYYYY: 06 2006 06 2006
YY YYYY wYY wYYYY: 03 2003 04 2004
WW 0WW: 6 06
MM 0MM MMM mmm MMMM mmmm: 2 02 Feb feb February february
DD 0DD DDD ddd DDDD dddd: 9 09 Thu thu Thursday thursday
hh 0hh: 2 02
mm 0mm: 6 06
ss 0ss: 8 08

Output should be:
YY YYYY wYY wYYYY: 06 2006 06 2006
YY YYYY wYY wYYYY: 03 2003 04 2004
WW 0WW: 6 06
MM 0MM MMM mmm MMMM mmmm: 2 02 February feb February february
DD 0DD DDD ddd DDDD dddd: 9 09 Thursday thu Thursday thursday
hh 0hh: 2 02
mm 0mm: 6 06
ss 0ss: 8 08

YY YYYY wYY wYYYY: 06 2006 06 2006
YY YYYY wYY wYYYY: 03 2003 04 2004
WW 0WW: 6 06
MM 0MM MMM mmm MMMM mmmm: 2 02 Feb feb February february
DD 0DD DDD ddd DDDD dddd: 9 09 Thu thu Thursday thursday
hh 0hh: 2 02
mm 0mm: 6 06
ss 0ss: 8 08


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jeremy Ruston  
View profile  
 More options May 8 2006, 6:35 am
From: "Jeremy Ruston" <jeremy.rus...@gmail.com>
Date: Mon, 8 May 2006 11:35:43 +0100
Local: Mon, May 8 2006 6:35 am
Subject: Re: Here's some support for week numbers
That's great, Martin, thanks so much. Yours are very thoughtful
contributions, and I hope you don't find the to-and-fro too
discouraging!

One minor point is that I was wondering what was the motivation for
the lower case weeks and days?

Also the chkDateFormatMmmDddAsFullName thing feels quite lumpy; I was
again curious about the motivation. I'd have expected that the
existing settings for 'MMM' and 'DDD' would stay the same, and that
anyone who wants to use the new, longer versions can do so by
explicitly specifying them. If anyone really, really wants to
retrospectively change existing 'MMM' and 'DDD' format date strings to
use the longer formats, it would seem reasonable to override
formatString() to redefine how those two strings get substituted, if
that makes sense.

Cheers

Jeremy

On 07/05/06, Martin Budden <mjbud...@gmail.com> wrote:

...

read more »


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Martin Budden  
View profile  
 More options May 8 2006, 2:00 pm
From: "Martin Budden" <mjbud...@gmail.com>
Date: Mon, 08 May 2006 11:00:43 -0700
Local: Mon, May 8 2006 2:00 pm
Subject: Re: Here's some support for week numbers
Jeremy,

to answer your two questions:

i) I agree that lower case day and month names is strictly unnecessary,
but they do serve a useful purpose: when tagging an item with a day or
month, generally the item is of prime importance and the date of
secondary importance. Keeping the day or month in lower case avoids
drawing the eye to it.

ii) Current behavior is:
MMMM - undefined
DDDD - undefined.
MMM - March (say)
DDD- Tuesday (say)

I'm changing it to
MMMM - March (say)
DDDD- Tuesday (say)
MMM - Mar (say)
DDD - Tue (say)

so I'm changing the behavior of MMM and DDD.

The chkDateFormatMmmDddAsFullName compatibility flag avoids breaking
any plugins that depend on the old MMM and DDD formats.

(By the way, I don't find the to and fro-ing discouraging, I'm glad you
want to get things right, and having a high bar to entry makes it that
much more satisfying if you do accept my code into the core.)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jeremy Ruston  
View profile  
 More options May 9 2006, 9:32 am
From: "Jeremy Ruston" <jeremy.rus...@gmail.com>
Date: Tue, 9 May 2006 14:32:56 +0100
Local: Tues, May 9 2006 9:32 am
Subject: Re: Here's some support for week numbers
Cool :)

In the interests of core size, I propose:

- we omit the lowercase month and day support, and delegate it to an
extension plugin
- we leave the behaviour of MMM and DDD as it is at the moment, to
avoid the complexity of adding another checkbox option
- we add MM3 and DD3 to signify the 3-letter abbreviated months and days

Of course, I'd have to embarrassedly agree that your remapping of MMMM
vs MMM is much more logical and usable, but I'm just concerned about
backwards compatibility.

Cheers

Jeremy.

On 08/05/06, Martin Budden <mjbud...@gmail.com> wrote:

--
Jeremy Ruston
mailto:jer...@osmosoft.com
http://www.tiddlywiki.com

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Martin Budden  
View profile  
 More options May 9 2006, 3:37 pm
From: "Martin Budden" <mjbud...@gmail.com>
Date: Tue, 09 May 2006 12:37:14 -0700
Local: Tues, May 9 2006 3:37 pm
Subject: Re: Here's some support for week numbers
I guess inclusion of lowercase support cannot really be justified. As
you say this can be delegated to a plugin (since the ddd dddd etc
formats remain unused).

MM3 and DD3 are fine as an alternative to my compatibility flag. I have
one request though: can you retain the MMMM and DDDD forms and make
them the "official" forms. This gives:

MMMM - official full monthname
MMM - deprecated full monthname, retained for compatibility
MM3 - abbreviated monthname.

ditto for days.

This means plugins can migrate to using the MMMM and DDDD forms, if
required, and at some point in the future it will be possible then
convert to using the MMM and DDD forms.

I know this is an additional two lines of code, but I've been reading
the code and I think I can find some savings elsewhere to "pay" for it.

Martin


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jeremy Ruston  
View profile  
 More options May 9 2006, 3:45 pm
From: "Jeremy Ruston" <jeremy.rus...@gmail.com>
Date: Tue, 9 May 2006 20:45:09 +0100
Local: Tues, May 9 2006 3:45 pm
Subject: Re: Here's some support for week numbers
Hi Martin - yes, I think that's a perfect approach. Many thanks,

Cheers

Jeremy.

On 09/05/06, Martin Budden <mjbud...@gmail.com> wrote:

--
Jeremy Ruston
mailto:jer...@osmosoft.com
http://www.tiddlywiki.com

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »