Skip to content

Instantly share code, notes, and snippets.

@bruno-rino
bruno-rino / datetime_from_iso.py
Last active October 10, 2017 07:57
Convert a ISO 8601 formatted datetime string to a python datetime. Supports basic and extended ISO 8601 formatting.
import re
from datetime import datetime, timedelta
from decimal import Decimal
def datetime_from_iso(text):
'''
Convert a ISO 8601 formatted datetime string to a python datetime
NOTE: this function is intentionally *not* timezone-aware; providing timezone information beyond 'Z' will fail.
NOTE: the parsing is sligthly too permissive; you can mix and match basic and extended ISO 8601 formatting (could be solved by using two regexes instead of one).
'''
io2:nixops rino$ nix-build ./release.nix -A build.i686-linux
these derivations will be built:
/nix/store/0b40wly7cbsnbxhrgx2hvhmdl2yhwc0f-options-db.xml.drv
/nix/store/0msg7qbxs44qmdi1gxjn10pari8j7qfm-options-db.xml.drv
/nix/store/1hjn16znczwy2iapld0n8pq0vmdl9vfy-options-db.xml.drv
/nix/store/1if4az5qmqqsr0afw6anx6gcjs5q2jyp-options-db.xml.drv
/nix/store/22b68cxmxp8s57akmdhzjcm5hd5sq69z-options-db.xml.drv
/nix/store/3391sr77akz829pdvjm883ii17z3zhqg-options-db.xml.drv
/nix/store/4j80j5myni0v34x3f62g76a2rpp8a07c-options-db.xml.drv
/nix/store/7ldfd2y0ib42dskyz8j4jpgpxpgyjacg-options-db.xml.drv