Exemplo n.º 1
0
    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
Exemplo n.º 2
0
    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
Exemplo n.º 3
0
    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
Exemplo n.º 4
0
    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
Exemplo n.º 5
0
    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
Exemplo n.º 6
0
    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
Exemplo n.º 7
0
    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
Exemplo n.º 8
0
    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