question

Abel van der Windt avatar image
1 Like"
Abel van der Windt asked Kavika F answered

Bug DateTime using day of the week

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

FlexSim 23.1.0
datetime
datetimebug.fsm (24.7 KiB)
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Matthew Gillespie avatar image
1 Like"
Matthew Gillespie answered

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.

5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Kavika F avatar image
0 Likes"
Kavika F answered

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.

5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.