PgSqlTimeStamp <-> DateTimeOffset conversion

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for PostgreSQL
Post Reply
acerbitdrain
Posts: 10
Joined: Sat 07 Feb 2009 10:09

PgSqlTimeStamp <-> DateTimeOffset conversion

Post by acerbitdrain » Thu 22 Oct 2009 11:36

What is your recommended practice for converting PgSqlTimeStamp to DateTimeOffset and vice versa?

Thank you.

Shalex
Site Admin
Posts: 8245
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Fri 23 Oct 2009 11:37

Please make conversion in the following way:

Code: Select all

      PgSqlTimeStamp time = new PgSqlTimeStamp(2009,10,22);
      //checking if PgSqlTimeStamp in the range of DateTime
      if ((time.CompareTo(new PgSqlTimeStamp(1, 1, 1, 0, 0, 0)) >= 0) && (time.CompareTo(new PgSqlTimeStamp(9999, 12, 31, 23, 59, 59))  PgSqlTimeStamp
        time = dt.DateTime;
      }

Post Reply