Example #1
0
def time2date(x):
    """
    This is the same as epoch2num.
    It converts time in sec since epoch to matplotlib date format.
    Can do the recerse with num2epoch
    """
    return x/(24.*3600)+pylab.epoch2num(0)
Example #2
0
def time2date(x):
    """
    This is the same as epoch2num.
    It converts time in sec since epoch to matplotlib date format.
    Can do the recerse with num2epoch
    """
    return x / (24. * 3600) + pylab.epoch2num(0)
Example #3
0
def str_epoch2num(s):
    """
    input is either a string or and time in seconds since epoch
    output is the date format of matplotlib
    Without a timezone in the input string, the local timezone is used.
    To enter a timezone you can use UTC, GMT,Z or something like
    -0500. It also knows about EST and DST.
    """
    if isinstance(s, basestring):
        # we replace pylab.datestr2num to better handle local timezone
        dt = dateutil.parser.parse(s, tzinfos=_TZOFFSETS)
        if dt.tzinfo is None:
            dt = dt.replace(tzinfo=dateutil.tz.tzlocal())
        return pylab.date2num(dt)
    else:
        return pylab.epoch2num(s)
Example #4
0
def str_epoch2num(s):
    """
    input is either a string or and time in seconds since epoch
    output is the date format of matplotlib
    Without a timezone in the input string, the local timezone is used.
    To enter a timezone you can use UTC, GMT,Z or something like
    -0500. It also knows about EST and DST.
    """
    if isinstance(s, basestring):
        # we replace pylab.datestr2num to better handle local timezone
        dt = dateutil.parser.parse(s, tzinfos=_TZOFFSETS)
        if dt.tzinfo is None:
            dt = dt.replace(tzinfo=dateutil.tz.tzlocal())
        return pylab.date2num(dt)
    else:
        return pylab.epoch2num(s)