new Date returns incorrect value

Discuss all problems you have with Servoy here. It might help to mention the Servoy version and Operating System version you are using

new Date returns incorrect value

Postby ylockson » Thu Mar 21, 2013 12:15 pm

new Date(2012, 12, 31) returns Thu Jan 31 00:00:00 MUT 2013
ylockson
 
Posts: 59
Joined: Thu Mar 01, 2012 8:40 am

Re: new Date returns incorrect value

Postby ROCLASI » Thu Mar 21, 2013 12:51 pm

No, this is actually a correct date.
Months in new Date() are zero-based. So december is actually 11.
Using 12 would push the whole date to the next year.
Robert Ivens
SAN Developer / Servoy Valued Professional / Servoy Certified Developer

ROCLASI Software Solutions / JBS Group, Partner
Mastodon: @roclasi
--
ServoyForge - Building Open Source Software.
PostgreSQL - The world's most advanced open source database.
User avatar
ROCLASI
Servoy Expert
 
Posts: 5438
Joined: Thu Oct 02, 2003 9:49 am
Location: Netherlands/Belgium

Re: new Date returns incorrect value

Postby ylockson » Thu Mar 21, 2013 5:27 pm

Understandable but not intuitive. To be consistent, the first date of the month should be 0...
ylockson
 
Posts: 59
Joined: Thu Mar 01, 2012 8:40 am

Re: new Date returns incorrect value

Postby mboegem » Thu Mar 21, 2013 6:08 pm

ylockson wrote:Understandable but not intuitive. To be consistent, the first date of the month should be 0...


and what about the year
let's start at 1 B.C.... :mrgreen:
Marc Boegem
Solutiative / JBS Group, Partner
Servoy Specialist
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image
User avatar
mboegem
 
Posts: 1750
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: new Date returns incorrect value

Postby jgarfield » Thu Mar 21, 2013 11:06 pm

ylockson wrote:Understandable but not intuitive. To be consistent, the first date of the month should be 0...


True, but that's the way the ECMAScript spec (http://www.ecma-international.org/ecma-262/5.1/#sec-15.9.1.4) is written.

If you want to use 1 based months you can always do
Code: Select all
new Date('2013/01/20');
new Date('01/20/2013');


Each of those will return Jan 20, 2013
Programmer.
adBlocks
http://www.adblocks.com
jgarfield
 
Posts: 223
Joined: Wed Sep 28, 2005 9:02 pm
Location: Boston, US

Re: new Date returns incorrect value

Postby ylockson » Sun Mar 24, 2013 6:19 am

jgarfield,

Thanks for your input.

I am new to Servoy & Javascript and came to realize that Servoy's methods needed to mimick Javascript's exactly identically. I also realized that often times, it is better to google 'how to ... in javascript' than to search Servoy's wikis.

Regards.
ylockson
 
Posts: 59
Joined: Thu Mar 01, 2012 8:40 am

Re: new Date returns incorrect value

Postby ROCLASI » Mon Mar 25, 2013 9:49 am

ylockson wrote:I am new to Servoy & Javascript and came to realize that Servoy's methods needed to mimick Javascript's exactly identically. I also realized that often times, it is better to google 'how to ... in javascript' than to search Servoy's wikis.

Actually Servoy's methods are not mimicking JavaScript. It is JavaScript. It's just that you are coding against the Servoy Object Model (SOM) instead of the Document Object Model in a web-browser (DOM). So the objects are different, the language is the same.
And true, I believe Servoy's wiki assumes some level of JavaScript knowledge. But as you said there are plenty of sources on the web that have very good JavaScript primers.
Robert Ivens
SAN Developer / Servoy Valued Professional / Servoy Certified Developer

ROCLASI Software Solutions / JBS Group, Partner
Mastodon: @roclasi
--
ServoyForge - Building Open Source Software.
PostgreSQL - The world's most advanced open source database.
User avatar
ROCLASI
Servoy Expert
 
Posts: 5438
Joined: Thu Oct 02, 2003 9:49 am
Location: Netherlands/Belgium


Return to Discuss possible Issues and Bugs

Who is online

Users browsing this forum: No registered users and 8 guests

cron