JuliaCon / JuliaCon.jl

JuliaCon. Everywhere.
MIT License
75 stars 9 forks source link

Wrong session for local time zone #22

Closed tk3369 closed 3 years ago

tk3369 commented 3 years ago

Related to #19, I can now pass a ZonedDateTime to today function. The time being displayed is correct but the session info do not match and is shifted by 1 day.

My current time is July 24 6:15 PM in Los Angeles. It displays 7:00 correctly, but the sessions being displayed is from July 25 rather than July 24.

julia> JuliaCon.today(; now = now(tz"America/Los_Angeles"))

Saturday 24 July 2021

Red
╭───────┬───────────────────────────────────────────────────────────┬──────┬───────────────────────────────────────╮
│ Time  │ Title                                                     │ Type │ Speaker                               │
├───────┼───────────────────────────────────────────────────────────┼──────┼───────────────────────────────────────┤
│ 07:00 │ Modeling Marine Ecosystems At Multiple Scales Using Julia │  W   │ Gael Forget, Benoit Pasquier, Zhen Wu │
╰───────┴───────────────────────────────────────────────────────────┴──────┴───────────────────────────────────────╯

Green
╭───────┬─────────────────────────────────────────────────────────────┬──────┬────────────────╮
│ Time  │ Title                                                       │ Type │ Speaker        │
├───────┼─────────────────────────────────────────────────────────────┼──────┼────────────────┤
│ 07:00 │ Parse and broker (log) messages with CombinedParsers(.EBNF) │  W   │ Gregor Kappler │
╰───────┴─────────────────────────────────────────────────────────────┴──────┴────────────────╯

Cc: @Azzaare

carstenbauer commented 3 years ago

The issue here is that

julia> la = ZonedDateTime(Dates.DateTime("2021-07-24T18:15:00.000"), tz"America/Los_Angeles");

julia> utc = astimezone(la, tz"UTC")
2021-07-25T01:15:00+00:00

i.e. in JuliaCon time (UTC) it was already the 25th of July.

carstenbauer commented 3 years ago

Perhaps unfortunately, this is expected behavior with the current implementation. The question really is what "today" means. When I wrote this package, admittedly not thinking about time zones too much, I chose the ad-hoc definition: JuliaCon.today == one day of JuliaCon (UTC). Within this day, convert the times accordingly.

Another, perhaps better/more intuitive definition would have been JuliaCon.today == all JuliaCon talks that happen on my day (local timezone). So, talks from different JuliaCon days (UTC) may show up in JuliaCon.today because your localzone might, say, include late evening talks on JCon day X + early morning talks on JCon day X + 1.

Given the data structure of the JuliaCon schedule (it's basically sorted/nested by JuliaCon days) the first definition of "today" was "natural" and straightforward to implement (find the current JuliaCon day and list all talks). If we want the second meaning, we should probably convert this data structure into, say, a big dataframe containing all the talks with all information and then select all the talks that happen on a given day (in an arbitrary time zone).

Frankly, I don't know if I have enough free time to implement this change (essentially a rewrite of the schedule logic). I plan to give it a try before Wednesday but can't promise anything. If this is much desired, @tk3369 maybe you want to give it a try in a PR?

carstenbauer commented 3 years ago

Created a PR in #23. Would be great if you could check it out and test it a bit @tk3369. Afterwards, I can merge this and tag a new release.

tk3369 commented 3 years ago

Thanks. I just saw both comments above. I will test shortly.

tk3369 commented 3 years ago

Looks ok. I've put my dev branch up on JuliaCon's server. You can test some more there.

If everything's alright, you can go ahead and merge yours and I'll do the same to mind. Then we'll just get it ready by tomorrow, right before JuliaCon!

Thanks for the quick turnaround :-)

carstenbauer commented 3 years ago

Merged into master and tagged a new release.