PgSqlTimeStamp <-> DateTimeOffset conversion

PgSqlTimeStamp <-> DateTimeOffset conversion

Postby acerbitdrain » Thu 22 Oct 2009 11:36

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

Thank you.
acerbitdrain
 
Posts: 10
Joined: Sat 07 Feb 2009 10:09

Postby 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)) <= 0)) {
        DateTimeOffset dt = (DateTimeOffset)time.Value;
        //implicit conversion DateTime -> PgSqlTimeStamp
        time = dt.DateTime;
      }
Shalex
Devart Team
 
Posts: 7654
Joined: Thu 14 Aug 2008 12:44


Return to dotConnect for PostgreSQL