View Bug Report | ||||||||||||||
|
Notes | Sort Options |
By: sirinsidiator - 12/29/20 11:04 AM |
Thanks for the report. Guess I'll just change it back to the old value for now, but it makes me wonder if it wouldn't be better to somehow fix CalculateIsoWeekAndYear so it will return the correct year for these edge cases. |
By: Shredder121 - 12/29/20 07:00 PM |
> TODO need to check if this is still relevant now that the trading week starts on Tuesday The adjustment to Thursday is still relevant, in other languages we have a YY format, for ISO8601 weekyear calculations, but Lua IIRC doesn't have that, so we have to do a regular yy format, *on* the Thursday in that week to emulate that. What could be done, is maybe a %w format of the turnaround time to get the week day, then subtract that from THURSDAY (4) to get the delta number of days for reaching that Thursday. This way no babysitting is needed after a patch, and would also work if *theoretically* a turnaround date is after a Thursday since the days to adjust would be negative to reach e.g. Friday (5-4=-1). |
By: Shredder121 - 12/29/20 07:31 PM |
>so we have to do a regular yy format of course, read this as %Y, but it functions as yyyy (calendar year) as in other languages >and would also work if *theoretically* a ~turnaround~ cycle date is after a Thursday Not quite certain at the moment anymore if that works for all values, especially Sunday, since in ISO8601 weeks start on Mondays, where in Lua the week starts on Sunday, and I'm not quite sure which start-of-week the %V and %Y follow. I think Sunday as well. Anyway, might be worth keeping an eye on. |
By: sirinsidiator - 12/30/20 06:00 AM |
Lua simply uses strftime directly underneath os.date, meaning all the same format specifiers are available: http://www.cplusplus.com/reference/ctime/strftime/ The Lua docs just left out the ones marked yellow, since they may not have be available on all platforms in the past, but today they work at least everywhere ESO is supported. Unfortunately it doesn't seem like it offers a format to get the iso year in addition to the iso week (unless %G is meant to be that?). My plan is to write testcases for CalculateIsoWeekAndYear and then fix it so it will work for all timestamps. The idea with subtracting the weekday doesn't sound bad - will definitely give it a try. |
By: Shredder121 - 12/31/20 05:22 PM |
Just reporting back, right now %G%V looks like the way to go. today %G%V = 202053 Will keep this debug line in to see when the week switches, but it looks like this could be used as format specifier, without having to jump to the Thursday, and also this format could be done in one pass. To extract the data the SeparateIsoWeekAndYear can still be used. |
By: Shredder121 - 01/03/21 05:06 PM |
Just reporting back, again. Just now today's %G%V returns 202101, so if the Tuesday's %G%V is used, the format is always correct. Oh and by the way, happy new year! |
By: sirinsidiator - 01/04/21 05:45 AM |
Happy New Year and thanks for testing this. I'll make sure to use that method instead of the current formatter to avoid future problems. |