def epoch_now_constructor(loader, node): """Return a function that returns the current epoch.""" delta = get_timedelta(loader.construct_scalar(node)) def get_now(): return datetime_to_epoch_timestamp( datetime.datetime.utcnow() + delta) return get_now
def epoch_now_constructor(loader, node): """Return a function that returns the current epoch.""" delta = get_timedelta(loader.construct_scalar(node)) def get_now(): return datetime_to_epoch_timestamp(datetime.datetime.utcnow() + delta) return get_now
def epoch_now_in_ms_constructor(loader, node): """Return a function that returns the current epoch in milliseconds. :rtype: int """ delta = get_timedelta(loader.construct_scalar(node)) def get_now(): return datetime_to_epoch_in_ms(datetime.datetime.utcnow() + delta) return get_now
def now_constructor(loader, node): """Return a function that returns the current datetime.""" delta = get_timedelta(loader.construct_scalar(node)) def get_now(): returned = datetime.datetime.utcnow() if TIMEZONE_AWARE: returned = returned.replace(tzinfo=pytz.utc) return returned + delta return get_now
def now_naive_constructor(loader, node): """Return a function that returns the current datetime. The returned datetime is always a naive datetime (i.e. without timezone information). See the introduction in `datetime <https://docs.python.org/2/library/datetime.html>`_ for more information. """ delta = get_timedelta(loader.construct_scalar(node)) def get_now(): return datetime.datetime.utcnow() + delta return get_now