Solved

StringToMoment giving weird result

  • 22 November 2023
  • 3 replies
  • 41 views

Userlevel 5
Badge +7

When using the StringToMoment function to calculate the number of hours between two dates and running into something weird:

 

As you can see AIMMS tells me 0 minutes elapsed between 10:00:00 and 11:00:00

 

My guess is that somehow AIMMS is assuming the referencedate as UTC time, while it assumes the second date as my local timezone.

I have also tried to use 

StringToMoment("%c%y-%m-%d %H:%M:%S %TZ", [minute], "2023-10-11 10:00:00" , "2023-10-11 11:00:00 UTC")

To indicate I really want to have the second timestamp as UTC, but that did not help.

 

What is the small/obvious thing I am overlooking here?

icon

Best answer by MarcelRoelofs 23 November 2023, 17:17

View original

3 replies

Userlevel 4
Badge +5

@gdiepen 

Maybe set this option that has helped me at times: use_UTC_forCaseAndStartEndDate

 

Userlevel 5
Badge +7

@MarcelRoelofs That is helping….

 

When I just checked in my project that was created a couple of days ago, this option was set to the non-default value “On”. After switching this option back to the default value “off” then everything was working as expected.

 

In the help it is mentioned that the default is different for new projects vs existing projects, but does not make it super clear.

 

Happpy that I do have a fix now, but a bit surprised the defaults in a new project do not lead to expected results without modifying some project settings

Userlevel 4
Badge +5

yeah, we went meticulously through a lot of things when introducing multi-time zone support in WebUI, but both for time zone support and character encodings the same thing is true: it is made easy to do wrong, and hard to do right. 

Reply


Didn't find what you were looking for? Try searching on our documentation pages:

AIMMS Developer & PRO | AIMMS How-To | AIMMS SC Navigator