Files
edx-platform/common/lib/xmodule/xmodule/timeparse.py
Victor Shnayder b782e2ff5d Make start dates work for all modules
* error modules now hidden via access control
* get_module() returns None if user doesn't have access
2012-08-14 23:30:37 -04:00

20 lines
474 B
Python

"""
Helper functions for handling time in the format we like.
"""
import time
TIME_FORMAT = "%Y-%m-%dT%H:%M"
def parse_time(time_str):
"""
Takes a time string in TIME_FORMAT, returns
it as a time_struct. Raises ValueError if the string is not in the right format.
"""
return time.strptime(time_str, TIME_FORMAT)
def stringify_time(time_struct):
"""
Convert a time struct to a string
"""
return time.strftime(TIME_FORMAT, time_struct)