示例#1
0
def utc_time_now():
    """Get the current date and time in UTC

    @returns a Python `datetime.datetime` object in UTC
    """
    gps = _gps_time_now()
    return gps_to_utc(gps)
示例#2
0
文件: gpstime.py 项目: farr/lalsuite
def utc_time_now():
    """Get the current date and time in UTC

    @returns a Python `datetime.datetime` object in UTC
    """
    gps = _gps_time_now()
    return gps_to_utc(gps)
示例#3
0
def str_to_gps(time_string=None):
    """Converts a date/time string into a GPS time.

    The following special words are permitted:
        - "now"
        - "today"
        - "yesterday"
        - "tomorrow"

    Example:
    \code
    >>> gpstime.str_to_gps("September 14 2011, 01:46:25")
    1000000000.000000000
    \endcode

    @returns a LIGOTimeGPS
    """
    if not time_string or time_string.lower() == "now":
        return _gps_time_now()
    elif time_string == "today":
        date = _datetime.date.today()
        return utc_to_gps(_datetime.datetime.combine(date, _datetime.time()))
    elif time_string == "tomorrow":
        today = _datetime.datetime.combine(_datetime.date.today(),
                                           _datetime.time())
        tomorrow = today + _datetime.timedelta(days=1)
        return utc_to_gps(tomorrow)
    elif time_string == "yesterday":
        today = _datetime.datetime.combine(_datetime.date.today(),
                                           _datetime.time())
        yesterday = today - _datetime.timedelta(days=1)
        return utc_to_gps(yesterday)
    # otherwise parse the string as a date/time
    utc = str_to_utc(time_string, tzinfos=TIME_ZONES)
    micro = utc.microsecond
    gps = utc_to_gps(utc)
    return gps + micro / 1000000.0
示例#4
0
文件: gpstime.py 项目: farr/lalsuite
def str_to_gps(time_string=None):
    """Converts a date/time string into a GPS time.

    The following special words are permitted:
        - "now"
        - "today"
        - "yesterday"
        - "tomorrow"

    Example:
    \code
    >>> gpstime.str_to_gps("September 14 2011, 01:46:25")
    1000000000.000000000
    \endcode

    @returns a LIGOTimeGPS
    """
    if not time_string or time_string.lower() == "now":
        return _gps_time_now()
    elif time_string == "today":
        date = _datetime.date.today()
        return utc_to_gps(_datetime.datetime.combine(date, _datetime.time()))
    elif time_string == "tomorrow":
        today = _datetime.datetime.combine(_datetime.date.today(),
                                           _datetime.time())
        tomorrow = today + _datetime.timedelta(days=1)
        return utc_to_gps(tomorrow)
    elif time_string == "yesterday":
        today = _datetime.datetime.combine(_datetime.date.today(),
                                           _datetime.time())
        yesterday = today - _datetime.timedelta(days=1)
        return utc_to_gps(yesterday)
    # otherwise parse the string as a date/time
    utc = str_to_utc(time_string, tzinfos=TIME_ZONES)
    micro = utc.microsecond
    gps = utc_to_gps(utc)
    return gps + micro / 1000000.0
示例#5
0
def gps_time_now():
    """Get the current time in GPS seconds

    @returns a LIGOTimeGPS
    """
    return _gps_time_now()
示例#6
0
文件: gpstime.py 项目: farr/lalsuite
def gps_time_now():
    """Get the current time in GPS seconds

    @returns a LIGOTimeGPS
    """
    return _gps_time_now()