def strftime(format, tt=None): # pylint: disable=missing-docstring,redefined-builtin t = Unix(int(mktime(tt)), 0) if tt else Now() ret = [] prev, n = 0, format.find('%', 0, -1) while n != -1: ret.append(format[prev:n]) next_ch = format[n + 1] c = _strftime_directive_map.get(next_ch) if c is NotImplemented: raise NotImplementedError('Code: %' + next_ch + ' not yet supported') if c: ret.append(t.Format(c)) else: ret.append(format[n:n+2]) n += 2 prev, n = n, format.find('%', n, -1) ret.append(format[prev:]) return ''.join(ret)
def seed(self, a=None): """Seed the golang.math.rand generator.""" if a is None: a = Now().UnixNano() Seed(a)
def localtime(seconds=None): t = (Unix(seconds, 0) if seconds else Now()).Local() return struct_time((t.Year(), t.Month(), t.Day(), t.Hour(), t.Minute(), t.Second(), (t.Weekday() + 6) % 7, t.YearDay(), 0))
def time(): return float(Now().UnixNano()) / Second
def time(): return float(Now().UnixNano()) / Second def strftime(format, tt=None): # pylint: disable=missing-docstring,redefined-builtin t = Unix(int(mktime(tt)), 0) if tt else Now() ret = [] prev, n = 0, format.find('%', 0, -1) while n != -1: ret.append(format[prev:n]) next_ch = format[n + 1] c = _strftime_directive_map.get(next_ch) if c is NotImplemented: raise NotImplementedError('Code: %' + next_ch + ' not yet supported') if c: ret.append(t.Format(c)) else: ret.append(format[n:n+2]) n += 2 prev, n = n, format.find('%', n, -1) ret.append(format[prev:]) return ''.join(ret) # TODO: Calculate real value for daylight saving. daylight = 0 # TODO: Use local DST instead of ''. tzname = (Now().Zone()[0], '')