Exemple #1
0
 def __repr__(self):
     ymd = hms = 0
     (ymd, hms) = _rmn.newdate(_rmn.NEWDATE_STAMP2PRINT, self.datev)
     if self.dt == 0:
         return "RPNDate({0:08d}, {1:08d})".format(ymd, hms)
     else:
         ymd0 = hms0 = 0
         (ymd0, hms0) = _rmn.newdate(_rmn.NEWDATE_STAMP2PRINT, self.dateo)
         return "RPNDate({0:08d}, {1:08d}) ; RPNDate({2:08d}, {3:08d}, dt={4:8.1f}, nstep={5:8.1f})".format(ymd, hms, ymd0, hms0, self.dt, self.nstep)
Exemple #2
0
    def toDateTime(self):
        """Return the DateTime obj representing the RPNDate

        >>> myRPNDate = RPNDate(20030423, 11453600)
        >>> myDateTime = myRPNDate.toDateTime()
        >>> myDateTime
        datetime.datetime(2003, 4, 23, 11, 45, 35, tzinfo=<UTC>)

        #TODO: oups 1 sec diff!!!
        """
        ymd = hms = 0
        (ymd, hms) = _rmn.newdate(_rmn.NEWDATE_STAMP2PRINT, self.datev)
        d = "{0:08d}.{1:08d}".format(ymd, hms)
        yyyy = int(d[0:4])
        mo = int(d[4:6])
        dd = int(d[6:8])
        hh = int(d[9:11])
        mn = int(d[11:13])
        ss = int(d[13:15])
        cs = int(d[15:17])
        utc = pytz.timezone("UTC")
        return datetime.datetime(yyyy, mo, dd, hh, mn, ss, cs*10000, tzinfo=utc)
Exemple #3
0
 def __init__(self, mydate, hms=None, dt=None, nstep=None):
     self.__updated = 1
     self.__datev   = 0
     self.__dict__['dateo'] = 0
     self.__dict__['dt']    = 0
     self.__dict__['nstep'] = 0
     if isinstance(mydate, datetime.datetime):
         (yyyy, mo, dd, hh, mn, ss, dummy, dummy2, dummy3) = \
             mydate.utctimetuple()
         cs = int(mydate.microsecond//10000)
         mydate = yyyy*10000+mo*100+dd
         hms = hh*1000000+mn*10000+ss*100+cs
         RPNDate.__init__(self, mydate, hms, dt=dt, nstep=nstep)
     elif isinstance(mydate, RPNDate):
         self.dateo = mydate.dateo
         self.dt  = mydate.dt
         self.nstep = mydate.nstep
     elif not type(mydate) == type(0):
         try:
             RPNDate.__init__(self, mydate.dateo, dt=mydate.deet,
                              nstep=mydate.npas)
         except:
             raise TypeError('RPNDate: Cannot instanciate with arg of type :'
                              + str(type(mydate)))
     else:
         if hms is None:
             self.dateo = mydate
         else:
             if not type(hms) == type(0):
                 raise TypeError, 'RPNDate: arguments should be of type int'
             dummy=0
             self.dateo = _rmn.newdate(_rmn.NEWDATE_PRINT2STAMP, mydate, hms)
     if not dt is None:
         self.dt = dt
     if not nstep is None:
         self.nstep = nstep
     self.__update(1)
Exemple #4
0
 def __str__(self):
     ymd = hms = 0
     (ymd, hms) = _rmn.newdate(_rmn.NEWDATE_STAMP2PRINT, self.datev)
     return "{0:08d}.{1:08d}".format(ymd, hms)