Bug DateTime using day of the week

Bug DateTime using day of the week

abel_vanderwindt
Contributor Contributor
455 Views
2 Replies
Message 1 of 3

Bug DateTime using day of the week

abel_vanderwindt
Contributor
Contributor

[ FlexSim 23.1.0 ]

In the attached model, it doesn't matter which day of the week is completed in the string date in the script window. Every day of the week gives the same result, where you would expect that changing the day changes the result. This is true for every format for day of the week. (%a, %A & %w)

DateTimebug.fsm

Accepted solutions (1)
456 Views
2 Replies
Replies (2)
Message 2 of 3

Matthew_Gillespie
Autodesk
Autodesk
Accepted solution

I don't think the DateTime constructor is meant to work with just a day of the week. A specific date can have a day of the week, but a day of the week can't be turned into a specific date. If you want a DateTime that is a certain number of days you can use the other overload of the constructor:

return DateTime(5, 16, 55).value;

That returns a DateTime that is 5 days, 16 hours, and 55 minutes long.



Matthew Gillespie
FlexSim Software Developer

Message 3 of 3

kavika_faleumu
Autodesk
Autodesk

Hey @Abel van der Windt, I think this is intended behavior. You're supplying the DateTime constructor with a day and a time. Given no other context as to the month or year, it decides that you want a length of time. That is why, regardless of the day you provide, it simply measures your time from 00:00 of that day.

If provided with a month and year, it can pinpoint your time in comparison to the number of seconds since January 1st, 1601, then it can provide you with a different value with a changed day.

0 Likes