def ctime(self): """Return a string representing the date and time. >>> datetime(1392, 9, 1, 12, 32, 14, 992).ctime() 'Fri Aza 01 12:32:14 1392' """ return jctime(jmktime(self.__jtm.copy()))
def gregorian_from_jalali(date_or_datetime): """ Make Gregorian :class:`python:datetime.datetime` from Jalali :class:`.datetime` or make Gregorian :class:`python:datetime.date` from Jalali :class:`.date`. >>> gregorian_from_jalali(datetime(1392, 9, 2, 23, 10, 2)) datetime.datetime(2013, 11, 23, 23, 10, 2) >>> gregorian_from_jalali(datetime(1392, 6, 30, 22, 30)) datetime.datetime(2013, 9, 21, 22, 30) >>> gregorian_from_jalali(date(1392, 6, 30)) datetime.date(2013, 9, 21) """ if isinstance(date_or_datetime, datetime): jdate = date_or_datetime.date() time = date_or_datetime.timetz() elif isinstance(date_or_datetime, date): jdate = date_or_datetime time = None else: raise TypeError('Expected Jalali %s or %s instance, not %s' % (datetime.__name__, date.__name__, date_or_datetime.__class__.__name__)) if jdate < date(1348, 10, 11): raise ValueError("Can't convert dates before Epoch") # to stop dst changes from bugging conversion, just convert date njtm = jdate.jtm.copy() gdate = _std_dt_mod.date.fromtimestamp(jmktime(njtm)) if time is None: return gdate return _std_dt_mod.datetime.combine(gdate, time)
def ctime(self): """Return a string representing the date and time. >>> datetime(1392, 9, 1, 12, 32, 14, 992).ctime() 'Jom Aza 01 12:32:14 1392' """ return jctime(jmktime(self.__jtm.copy()))
def ctime(self): """Return a string representing the date and time. >>> datetime(1392, 9, 1, 12, 32, 14, 992).ctime() 'Fri Aza 01 12:32:14 1392' """ # TODO: # this should be enough if jmktime fixed: # return jctime(jmktime(self.__jtm)) njtm = self.__jtm.copy() jalali_update(njtm) return jctime(jmktime(njtm))
def ctime(self): """Return a string representing the date, ``date(1392, 8, 2).ctime() == 'Thu Aba 02 00:00:00 1392'``""" njtm = self.__jtm.copy() return jctime(jmktime(njtm))