Leap Yr regular expression

R

Randy Webb

Dr John Stockton said the following on 2/19/2006 3:04 PM:
JRS: In article <[email protected]>,
dated Sun, 19 Feb 2006 00:57:52 remote, seen in
news:comp.lang.javascript said:
On 18/02/2006 18:08, Vladas Saulis wrote:

[snip]
When you create a date = YYYY.02.29 for a non-leap year, you get back
a YYYY.03.01. And the getMonth() for the "March" is equal to 2 (for
february = 1).

That's why I called it kinda an exploit (unexpected (for me)
behaviour).
However, it /is/ expected behaviour. The Date object is well-known for
handling out-of-range values by adjusting adjacent fields. It does this
by design.

For those who injudiciously put VBscript on Web pages,

There is nothing "injudicious" about putting VBScript on Web pages.

It's wise if you know when, its ignorant if you don't.
or who more sagaciously use VBscript in WSH :

Sesquipedalian behavior is a sign of ignorance, not intelligence.
 
T

Thomas 'PointedEars' Lahn

Vladas said:
Following this logic, then the date = YYYY.MM.00 should return the last
day of the previous month.
Correct.

Am I right?

You are.
(I have no time to test :).

Typing

javascript:window.alert(new Date(2000, 1, 0));

into your location bar and hit the Return key is too much for you?


PointedEars
 
D

Dr John Stockton

JRS: In article <op.s47pc7qy8lqgld@eightpee>, dated Sun, 19 Feb 2006
10:47:21 remote, seen in Vladas Saulis
Following this logic, then the date = YYYY.MM.00 should return the last
day of the previous month.
Am I right? (I have no time to test :).

Use the newsgroup FAQ, and you will learn such things; see below.

With at least one localisation new Date("2005.01.00") gives NaN, as
does new Date("2005-01-00") -- but new Date("2005/01/00")
gives me Fri Dec 31 00:00:00 UTC 2004 and should set the local
equivalent of that anywhere.

One can get St Andrew's Day as new Date((year+1)+"/0/0") .

Also read <URL:http://www.merlyn.demon.co.uk/js-quick.htm>.
 

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
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top