❔ Converting my project to NodaTime
Hi there, after some conversation in my previous partially related thread #Accounting for Daylight Savings Time skips at runtime, I'm planning on converting existing functionality in my project (a Discord bot) to NodaTime's types instead of the BCL types, to avoid issues that might occur from constantly converting to and from different time-related types.
There are a lot of classes in NodaTime that can be used to represent a "moment in time" so to speak, so I'd like to know which ones I should use for different situations.
Disclaimer: I am using EFCore with PostgreSQL, and will now be using
There are a lot of classes in NodaTime that can be used to represent a "moment in time" so to speak, so I'd like to know which ones I should use for different situations.
Disclaimer: I am using EFCore with PostgreSQL, and will now be using
Npgsql.EntityFrameworkCore.PostgreSQL.NodaTime for storing appropriate types.- Most of my database entities utilize
DateTimeOffsetfor their creation date and time - always stored in UTC as I believe EFCore cannot storeDateTimeOffsets with a non-UTC offset. I'm unsure whether to useOffsetDateTime,ZonedDateTime, orInstant. - Many classes implement a timer interface, and utilize a
DateTimeOffsetfor when the timer "expires". See the linked thread for issues related to Daylight Savings Time - I believe I will need to store aLocalTimeorInstantand convert it to the user's timezone at runtime (see next point) - Users can set their timezone via a command - allowing using https://github.com/robbell/nChronic.Core for natural date parsing in their local time, instead of using UTC for everything. I will likely store their timezone as
TimeZoneInfoinstead ofTimeSpanwhich I previously used.