You can't reliably determine anything about time zones from it except the datetime value came from a time zone when it was created. Either keep strictly to UTC and avoid the confusion or store a time zone identifier with it so you can perform meaningful conversions. Suncat, partly agree. I think it is all about developers' adherence to rules use set in the project. If you use DateTime you are dependent of a developer's current mood.
It is a little harder to fool DateTimeOffset. The solution can be to implement your class and stop using DateTime completely as you suggested to use two fields always - BTW. Ajay Sharma Ajay Sharma 2, 5 5 gold badges 20 20 silver badges 32 32 bronze badges.
The only difference is that it stores only the UTC offset for the particular instant in time that a DateTime represents. It does not store the actual time zone, so basically all you can do with it is convert between its relative local time and UTC. Helpful in some circumstances, but pretty weak information, otherwise. The Overflow Blog. Podcast Explaining the semiconductor shortage, and how it might end. An extra byte is added to the datetimeoffset value but not to the datetime value.
This is because the datetimeoffset value needs an extra byte to store the precision because the precision is user-defined. Many developers assume that converting to varbinary is representative of how SQL Server actually stores date and time values. However this is only partially true.
This is because the precision is included in the column definition. If not, then datetime may suffice. However, Microsoft recommends that you use datetime2 for new work, as it has many benefits over datetime. Which one is better, or is there any other suggestions?
DateTimeOffset Represents a point in time, typically expressed as a date and time of day, relative to Coordinated Universal Time UTC it provides a greater degree of time zone awareness than the DateTime structure. Newer versions of Ruby 2. Some libraries will use one or the other for historical reasons, but new code does not necessarily need to be concerned. Picking one for consistency is probably best, so try and mesh with what your libraries expect.
For example, ActiveRecord prefers DateTime. In versions prior to Ruby 1. The precise improvements and breaking changes are detailed in the 6. Use of the time with time zone type is discouraged, see the PostgreSQL documentation.
You can use a DateTimeOffset to read and write values - the date component will be ignored. PostgreSQL supports the special values -infinity and infinity for the timestamp and date types see docs ; these can be useful to represent a value which is earlier or later than any other value. Starting with Npgsql 6. To opt out of this behavior, set the following AppContext switch at the start of your application:.
0コメント