Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(2)  |  Call(1)  |  Derive(0)  |  Import(1)

        def new_datetime(d):
    '''Generate a safe "datetime" from a "datetime.date" or "datetime.datetime"
    object.

    '''
    args = [d.year, d.month, d.day]
    if isinstance(d, datetime.__base__):    # legacy datetime
        args.extend([d.hour, d.minute, d.second, d.microsecond, d.tzinfo])
    return datetime(*args)
        


src/x/o/xoutil-1.5.4/xoutil/json.py   xoutil(Download)
    def default(self, o):
        from decimal import Decimal as _Decimal
        from xoutil.types import is_iterable
        from xoutil.datetime import (is_datetime as _is_datetime,
                                     new_datetime as _new_datetime,
 
        if _is_datetime(o):
            d = _new_datetime(o)
            return d.strftime("%s %s" % (self.DATE_FORMAT, self.TIME_FORMAT))
        elif _is_date(o):