def new(self): # type: () -> None """ Create a new Directory Record date based on the current time. Parameters: tm - An optional argument that must be None Returns: Nothing. """ if self._initialized: raise pycdlibexception.PyCdlibInternalError( 'Directory Record Date already initialized') # This algorithm was ported from cdrkit, genisoimage.c:iso9660_date() tm = time.time() local = time.localtime(tm) self.years_since_1900 = local.tm_year - 1900 self.month = local.tm_mon self.day_of_month = local.tm_mday self.hour = local.tm_hour self.minute = local.tm_min self.second = local.tm_sec self.gmtoffset = utils.gmtoffset_from_tm(tm, local) self._initialized = True
def new(self, tm=0.0): # type: (float) -> None """ Create a new Volume Descriptor Date. If tm is None, then this Volume Descriptor Date will be full of zeros (meaning not specified). If tm is not None, it is expected to be a struct_time object, at which point this Volume Descriptor Date object will be filled in with data from that struct_time. Parameters: tm - struct_time object to base new VolumeDescriptorDate off of, or 0.0 for an empty VolumeDescriptorDate. Returns: Nothing. """ if self._initialized: raise pycdlibexception.PyCdlibInternalError( 'This Volume Descriptor Date object is already initialized') if tm != 0.0: local = time.localtime(tm) self.year = local.tm_year self.month = local.tm_mon self.dayofmonth = local.tm_mday self.hour = local.tm_hour self.minute = local.tm_min self.second = local.tm_sec self.hundredthsofsecond = 0 self.gmtoffset = utils.gmtoffset_from_tm(tm, local) self.date_str = time.strftime( self.TIME_FMT, local).encode('utf-8') + '{:0<2}'.format( self.hundredthsofsecond).encode('utf-8') + struct.pack( '=b', self.gmtoffset) else: self.year = 0 self.month = 0 self.dayofmonth = 0 self.hour = 0 self.minute = 0 self.second = 0 self.hundredthsofsecond = 0 self.gmtoffset = 0 self.date_str = self.EMPTY_STRING self._initialized = True
def new(self, tm=0.0): # type: (float) -> None ''' Create a new Volume Descriptor Date. If tm is None, then this Volume Descriptor Date will be full of zeros (meaning not specified). If tm is not None, it is expected to be a struct_time object, at which point this Volume Descriptor Date object will be filled in with data from that struct_time. Parameters: tm - struct_time object to base new VolumeDescriptorDate off of, or 0.0 for an empty VolumeDescriptorDate. Returns: Nothing. ''' if self._initialized: raise pycdlibexception.PyCdlibInternalError('This Volume Descriptor Date object is already initialized') if tm != 0.0: local = time.localtime(tm) self.year = local.tm_year self.month = local.tm_mon self.dayofmonth = local.tm_mday self.hour = local.tm_hour self.minute = local.tm_min self.second = local.tm_sec self.hundredthsofsecond = 0 self.gmtoffset = utils.gmtoffset_from_tm(tm, local) self.date_str = time.strftime(self.TIME_FMT, local).encode('utf-8') + '{:0<2}'.format(self.hundredthsofsecond).encode('utf-8') + struct.pack('=b', self.gmtoffset) else: self.year = 0 self.month = 0 self.dayofmonth = 0 self.hour = 0 self.minute = 0 self.second = 0 self.hundredthsofsecond = 0 self.gmtoffset = 0 self.date_str = self.EMPTY_STRING self._initialized = True
def new(self): # type: () -> None ''' Create a new Directory Record date based on the current time. Parameters: tm - An optional argument that must be None Returns: Nothing. ''' if self._initialized: raise pycdlibexception.PyCdlibInternalError('Directory Record Date already initialized') # This algorithm was ported from cdrkit, genisoimage.c:iso9660_date() tm = time.time() local = time.localtime(tm) self.years_since_1900 = local.tm_year - 1900 self.month = local.tm_mon self.day_of_month = local.tm_mday self.hour = local.tm_hour self.minute = local.tm_min self.second = local.tm_sec self.gmtoffset = utils.gmtoffset_from_tm(tm, local) self._initialized = True