Changeset 795

Show
Ignore:
Timestamp:
03/06/07 18:37:27 (1 year ago)
Author:
mfenniak
Message:

Add timestamp data type

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • pg8000/trunk/pg8000.py

    r794 r795  
    11import socket 
    22import struct 
     3import datetime 
    34import md5 
    45 
     
    396397 
    397398    def boolout(v): 
    398         if v: 
    399             return 't' 
    400         else: 
    401             return 'f' 
     399        # imp req. 
     400        pass 
    402401 
    403402    def int4in(data, description): 
     
    405404 
    406405    def int4out(v): 
    407         return str(v) 
     406        # imp req. 
     407        pass 
     408 
     409    def timestamp_in(data, description): 
     410        year = int(data[0:4]) 
     411        month = int(data[5:7]) 
     412        day = int(data[8:10]) 
     413        hour = int(data[11:13]) 
     414        minute = int(data[14:16]) 
     415        sec = int(data[17:19]) 
     416        return datetime.datetime(year, month, day, hour, minute, sec) 
     417 
     418    def timestamp_out(v): 
     419        # imp req. 
     420        pass 
    408421 
    409422    t_formats_text = { 
    410423        16: (boolin, boolout), 
    411424        23: (int4in, int4out), 
     425        1114: (timestamp_in, timestamp_out), 
    412426    } 
    413427