Exemplo n.º 1
0
        def __init__(self, locked=False):
            init_dict = self.__init_dict__
            for key in init_dict:
                value = init_dict[key]
                date, mo, da, ye, time, ho, mi, se = [None] * 8
                if type(value) in [str, str]:
                    date, da, mo, ye, time, ho, mi, se = reDateTime.match(
                        value).groups()
                    if mo and int(mo) > 12:
                        mo, da = da, mo

                if type(init_dict[key]) == dict:
                    setattr(self, key, makeFMData(
                        init_dict[key],
                        locked=False))  # lock all substructures??
                elif type(init_dict[key]) == list:
                    l = []
                    for d in init_dict[key]:
                        if type(d) == dict:
                            l.append(makeFMData(d))  # lock ??
                        else:
                            l.append(d)
                    setattr(self, key, l)
                elif date and time:
                    setattr(
                        self, key,
                        DateTime(int(ye), int(mo), int(da), int(ho), int(mi),
                                 int(se)))
                elif date:
                    setattr(self, key, Date(int(ye), int(mo), int(da)))
                elif time:
                    setattr(self, key, Time(int(ho), int(mi), int(se)))
                else:
                    setattr(self, key, init_dict[key])
            if locked:
                self.__modified__.add('__locked__')
Exemplo n.º 2
0
 def test_type_roundtrip_time_array(self):
     from mx.DateTime import Time
     self._test_type_roundtrip_array(Time(10, 20, 30))
Exemplo n.º 3
0
 def test_adapt_time(self):
     from mx.DateTime import Time
     value = self.execute('select (%s)::time::text', [Time(13, 30, 29)])
     self.assertEqual(value, '13:30:29')
Exemplo n.º 4
0
 def test_type_roundtrip_time_array(self):
     self._test_type_roundtrip_array(Time(10, 20, 30))
Exemplo n.º 5
0
 def test_type_roundtrip_time(self):
     self._test_type_roundtrip(Time(10, 20, 30))
 def test_time_optional_seconds(self):
     conv = SourceDataTypes.get_format('time', 'HH:MM')
     self.assertEqual(conv('12:23'), Time(12, 23))
     self.assertEqual(conv('12:23'), Time(12, 23, 0.0))
 def test_iso_time_leap_seconds(self):
     """Err, shouldn't some of these throw errors, even allowing for leap seconds?"""
     conv = SourceDataTypes.get_conversion('iso-time')
     self.assertEqual(conv('01:02:60.4'), Time(1, 2, 60.4))
     self.assertEqual(conv('01:02:61.4'), Time(1, 2, 61.4))
     self.assertEqual(conv('01:02:62.4'), Time(1, 2, 62.4))
Exemplo n.º 8
0
 def test_time(self):
     data = [Time(0,0), 
             Time(23,59,59), 
             Time(12,0,0),
             None]
     self._test_array(soomarray.ArrayTime, data)
Exemplo n.º 9
0
"""
Projman - (c)2000-2010 LOGILAB <*****@*****.**> - All rights reserved.

Home: http://www.logilab.org/projman

Manipulate a xml project description.

This code is released under the GNU Public Licence v2. See www.gnu.org.
"""

from mx.DateTime import DateTime, Time, Date
from logilab.common import testlib
from projman.lib import Project, Calendar, Resource

MORNING = (Time(8), Time(12))
AFTERNOON = (Time(13), Time(17))
HALFDAY = (Time(9), Time(15))

def mk_calendar1():
    cal = Calendar('c_1', 'Calendrier 1')
    cal.day_types = {'nonworking': ['Non working', []],
                     'working':    ['Working', [MORNING, AFTERNOON]],

                         'halfday':    ['HalfDay', [HALFDAY]],
                         }
    cal.default_day_type = 'working'
    cal.national_days = [(1,1), (12,25), (11,11)]
    cal.start_on = DateTime(2004,01,06)
    cal.stop_on = DateTime(2006,12,29)
    cal.weekday['mon'] = 'working'
    cal.weekday['tue'] = 'working'
Exemplo n.º 10
0
def TimeFromTicks(ticks):
    """Convert UNIX ticks into a mx.DateTime.Time."""
    return Time(*localtime(ticks)[3:6])