Skip to content

Instantly share code, notes, and snippets.

@simonw
Created August 25, 2009 09:44
Show Gist options
  • Select an option

  • Save simonw/174601 to your computer and use it in GitHub Desktop.

Select an option

Save simonw/174601 to your computer and use it in GitHub Desktop.
import datetime, time
def to_isoformat(dt):
return dt.isoformat().split('.')[0]
def from_isoformat(s):
s = s.split('.')[0]
return datetime.datetime(
*time.strptime(s, '%Y-%m-%dT%H:%M:%S')[:6]
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment