Showing posts with label programming. Show all posts
Showing posts with label programming. Show all posts

Sunday, July 14, 2024

Quick note: Python date and time objects

In Python, a naive datetime object is one that does not contain any information about time zones or daylight saving time. This means it is unaware of the context in which it exists, such as whether it represents local time, UTC, or any other time zone. By default, the datetime object in Python is naive. You can make them timezone aware using the pytz library.

If you are working with pandas dataframes or series, you can also use the tz_localize method of the Pandas DateTimeIndex object.



References:

Thursday, August 01, 2019

Code tip: Nullable datetime in C#

Nullable types are used when you need to represent the value of an underlying type. By default DateTime is not nullable in C# because it is a Value type, but using the Nullable construct (or the ? shorthand), you can assign the null literal to the DateTime type. Syntax is below:

 DateTime? dt = null;  
 Nullable<DateTime> dt = null;