def test_DTM(self):
        dtime  = datetime.strptime('2013', '%Y')
        dtime1 = datetime.strptime('201307', '%Y%m')
        dtime2 = datetime.strptime('20130715', '%Y%m%d')
        dtime3 = datetime.strptime('01', '%H')
        dtime4 = datetime.strptime('0101', '%H%M')
        dtime5 = datetime.strptime('010111', '%H%M%S')
        dtime6 = datetime.strptime('010111.1110', '%H%M%S.%f')
        dtime7 = datetime.strptime('20130715010111.1110', '%Y%m%d%H%M%S.%f')

        dtm  = DTM(dtime, out_format='%Y')
        dtm1 = DTM(dtime1, out_format='%Y%m')
        dtm2 = DTM(dtime2, out_format='%Y%m%d')
        dtm3 = TM(dtime3, out_format='%H')
        dtm4 = TM(dtime4, out_format='%H%M')
        dtm5 = TM(dtime5, out_format='%H%M%S')
        dtm6 = TM(dtime6, out_format='%H%M%S.%f')
        dtm7 = DTM(dtime7, out_format='%Y%m%d%H%M%S.%f')

        self.assertEqual(dtm.classname, 'DTM')
        self.assertEqual(dtm.to_er7(), '2013')
        self.assertEqual(dtm1.to_er7(), '201307')
        self.assertEqual(dtm2.to_er7(), '20130715')
        self.assertEqual(dtm3.to_er7(), '01')
        self.assertEqual(dtm4.to_er7(), '0101')
        self.assertEqual(dtm5.to_er7(), '010111')
        self.assertEqual(dtm6.to_er7(), '010111.1110')
        self.assertEqual(dtm7.to_er7(), '20130715010111.1110')
Exemple #2
0
    def test_DTM(self):
        dtime  = datetime.strptime('2013', '%Y')
        dtime1 = datetime.strptime('201307', '%Y%m')
        dtime2 = datetime.strptime('20130715', '%Y%m%d')
        dtime3 = datetime.strptime('01', '%H')
        dtime4 = datetime.strptime('0101', '%H%M')
        dtime5 = datetime.strptime('010111', '%H%M%S')
        dtime6 = datetime.strptime('010111.111', '%H%M%S.%f')
        dtime7 = datetime.strptime('20130715010111.111', '%Y%m%d%H%M%S.%f')

        dtm  = DTM(dtime, format='%Y')
        dtm1 = DTM(dtime1, format='%Y%m')
        dtm2 = DTM(dtime2, format= '%Y%m%d')
        dtm3 = TM(dtime3, format= '%H')
        dtm4 = TM(dtime4, format=  '%H%M')
        dtm5 = TM(dtime5, format= '%H%M%S')
        dtm6 = TM(dtime6, format= '%H%M%S.%f')
        dtm7 = DTM(dtime7, format= '%Y%m%d%H%M%S.%f')

        self.assertEqual(dtm.classname, 'DTM')
        self.assertEqual(dtm.to_er7(), datetime.strftime(dtime, dtm.format))
        self.assertEqual(dtm1.to_er7(), datetime.strftime(dtime1, dtm1.format))
        self.assertEqual(dtm2.to_er7(), datetime.strftime(dtime2, dtm2.format))
        self.assertEqual(dtm3.to_er7(), datetime.strftime(dtime3, dtm3.format))
        self.assertEqual(dtm4.to_er7(), datetime.strftime(dtime4, dtm4.format))
        self.assertEqual(dtm5.to_er7(), datetime.strftime(dtime5, dtm5.format))
        self.assertEqual(dtm6.to_er7(), datetime.strftime(dtime6, dtm6.format))
        self.assertEqual(dtm7.to_er7(), datetime.strftime(dtime7, dtm7.format))
        self.assertEqual(dtm7.to_er7(), datetime.strftime(dtime7, dtm7.format))
 def test_DTM_custom_microsec_precision(self):
     time = datetime.strptime('20130705011959.1234', '%Y%m%d%H%M%S.%f')
     tm = DTM(time, microsec_precision=1)
     self.assertEqual(tm.to_er7(), '20130705011959.1')
     tm = DTM(time, microsec_precision=2)
     self.assertEqual(tm.to_er7(), '20130705011959.12')
     tm = DTM(time, microsec_precision=3)
     self.assertEqual(tm.to_er7(), '20130705011959.123')
     tm = DTM(time, microsec_precision=4)
     self.assertEqual(tm.to_er7(), '20130705011959.1234')
Exemple #4
0
 def test_DTM_custom_microsec_precision(self):
     time = datetime.strptime('20130705011959.1234', '%Y%m%d%H%M%S.%f')
     tm = DTM(time, microsec_precision=1)
     self.assertEqual(tm.to_er7(), '20130705011959.1')
     tm = DTM(time, microsec_precision=2)
     self.assertEqual(tm.to_er7(), '20130705011959.12')
     tm = DTM(time, microsec_precision=3)
     self.assertEqual(tm.to_er7(), '20130705011959.123')
     tm = DTM(time, microsec_precision=4)
     self.assertEqual(tm.to_er7(), '20130705011959.1234')
Exemple #5
0
 def test_DTM_offset(self):
     dtime = datetime.strptime('20130715 010111.1110', '%Y%m%d %H%M%S.%f')
     dtm = DTM(dtime, offset='+0100')
     self.assertEqual(dtm.to_er7(), '20130715010111.1110+0100')
Exemple #6
0
 def test_DTM_default_format(self):
     dtime = datetime.strptime('20130715 010111.1110', '%Y%m%d %H%M%S.%f')
     dtm = DTM(dtime)
     self.assertEqual(dtm.to_er7(), '20130715010111.1110')
Exemple #7
0
    def test_DTM(self):
        dtime = datetime.strptime('2013', '%Y')
        dtime1 = datetime.strptime('201307', '%Y%m')
        dtime2 = datetime.strptime('20130715', '%Y%m%d')
        dtime3 = datetime.strptime('01', '%H')
        dtime4 = datetime.strptime('0101', '%H%M')
        dtime5 = datetime.strptime('010111', '%H%M%S')
        dtime6 = datetime.strptime('010111.1110', '%H%M%S.%f')
        dtime7 = datetime.strptime('20130715010111.1110', '%Y%m%d%H%M%S.%f')

        dtm = DTM(dtime, out_format='%Y')
        dtm1 = DTM(dtime1, out_format='%Y%m')
        dtm2 = DTM(dtime2, out_format='%Y%m%d')
        dtm3 = TM(dtime3, out_format='%H')
        dtm4 = TM(dtime4, out_format='%H%M')
        dtm5 = TM(dtime5, out_format='%H%M%S')
        dtm6 = TM(dtime6, out_format='%H%M%S.%f')
        dtm7 = DTM(dtime7, out_format='%Y%m%d%H%M%S.%f')

        self.assertEqual(dtm.classname, 'DTM')
        self.assertEqual(dtm.to_er7(), '2013')
        self.assertEqual(dtm1.to_er7(), '201307')
        self.assertEqual(dtm2.to_er7(), '20130715')
        self.assertEqual(dtm3.to_er7(), '01')
        self.assertEqual(dtm4.to_er7(), '0101')
        self.assertEqual(dtm5.to_er7(), '010111')
        self.assertEqual(dtm6.to_er7(), '010111.1110')
        self.assertEqual(dtm7.to_er7(), '20130715010111.1110')
 def test_DTM_offset(self):
     dtime = datetime.strptime('20130715 010111.1110', '%Y%m%d %H%M%S.%f')
     dtm = DTM(dtime, offset='+0100')
     self.assertEqual(dtm.to_er7(), '20130715010111.1110+0100' )
 def test_DTM_default_format(self):
     dtime = datetime.strptime('20130715 010111.1110', '%Y%m%d %H%M%S.%f')
     dtm = DTM(dtime)
     self.assertEqual(dtm.to_er7(), '20130715010111.1110')