org-scn-design-studio-community / sdkpackage

SDK Package of SCN Design Studio Community
Apache License 2.0
32 stars 29 forks source link

REALDATE Not Handling February 2017 Properly #161

Closed HenryTaylor closed 7 years ago

HenryTaylor commented 7 years ago

Design Studio 1.6 SP2 SCN Community Extensions 3.0

I have the following code that defines a date object:

glblEndDate = DS_MAX_RUN_AND_END_DATE.getDataAsStringExt("_90NhIuevEeauSNeZmHqg8A", {});

var date = glblEndDate.split("/");
var year = Convert.stringToInt(date[2]) + 2000;
var month = Convert.stringToInt(date[0]);
var day = Convert.stringToInt(date[1]);

REALDATE_1.initialize(year, month, day);
var mask = "mmm dd, yyyy"; // this is the format we want the dates in
glblEndDate = REALDATE_1.formatWithMask(mask, true);

When the value returned from the Datasource is '01/01/2017', this all works okay. But, when the value is "02/01/2017", the value of glblEndDate at the end of the code is "Mar 01, 2017", when it should be "Feb 01, 2017". It doesn't appear to me that the REALDATE.intialize() function is handling February properly. Even if I hard code the values, REALDATE.initialize(2017, 2, 1), the value of glblEndDate at the end is March.

MartinPankraz commented 7 years ago

Hi Henry,

I just tested with the latest release.

REALDATE_1.initialize(2017, 2, 1); var mask="mmm dd, yyyy"; var date = REALDATE_1.formatWithMask(mask, true); APPLICATION.alert(date);

That prompted me with Feb 01, 2017. So I would like to ask you to make sure you have the latest release of the repository installed. There were some fixes to the date component last year.

Kind regards Martin

HenryTaylor commented 7 years ago

I do have the most recent version. I'm very confused right now, though. I tried your code and it worked fine. So, I went back to my original code and it too works fine now. I know what I saw before, but I cannot reproduce those results. Man, it's things like this that really make you doubt your sanity.

Anyway, thanks for the response, and I guess there isn't a problem after all.

MartinPankraz commented 7 years ago

My first guess would be that your months were starting from 0: So index 0 would be January instead of 1. Something like that.

Thanks for replying.

Kind regards Martin