Example #1
0
 def index(self, x):
     d = iso8601.parse_date(x, default_timezone=None) \
         if (isinstance(x, unicode) or isinstance(x, str)) else x
     if not isinstance(d, datetime):
         raise ValueError('Only date time items or ISO date strings '
                          'allowed for date time lists') 
     err_str_c = c_char_p()
     index_c = c_int()
     timestamp_c = c_longlong(_datetime_to_time_t(d))
     pos = dickinson.dl_get_i(self.dl_handle, timestamp_c)
     if pos<0:
         raise KeyError('No such item (%s) in date time list'%\
                        (x,))
     return pos
Example #2
0
 def append(self, x):
     d = iso8601.parse_date(x, default_timezone=None) \
         if (isinstance(x, unicode) or isinstance(x, str)) else x
     if not isinstance(d, datetime):
         raise ValueError('Only date time items or ISO date strings '
                          'allowed for date time lists') 
     err_str_c = c_char_p()
     index_c = c_int()
     err_no_c = dickinson.dl_insert_record(self.dl_handle,
         c_longlong(_datetime_to_time_t(d)),
         byref(index_c), byref(err_str_c))
     if err_no_c!=0:
         raise Exception('Something wrong occured in dickinson '
             'function when setting a time series value. '+
             'Error message: '+repr(err_str_c.value))
Example #3
0
 def __contains__(self, item):
     index_c = dickinson.dl_get_i(self.dl_handle,
                                     c_longlong(_datetime_to_time_t(item)))
     return False if index_c<0 else True