summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Driessen <vincent@3rdcloud.com>2012-02-08 00:33:14 +0100
committerVincent Driessen <vincent@3rdcloud.com>2012-02-08 00:33:14 +0100
commitb23373cb33475fb9edba983a7d658d9105cc0a84 (patch)
treedbd6d787b03755491c11832ade89debd44bdf5cf
parentebcc4449325fd64f3441343c3f6274bfc2ac3e32 (diff)
downloadtimes-b23373cb33475fb9edba983a7d658d9105cc0a84.tar.gz
Update the README.
-rw-r--r--README.md23
1 files changed, 23 insertions, 0 deletions
diff --git a/README.md b/README.md
index 3d14651..71a3f69 100644
--- a/README.md
+++ b/README.md
@@ -48,6 +48,26 @@ To enforce best practices, `times` will never implicitly convert times for you,
even if that would technically be possible.
+Date Strings
+------------
+If you want to accepting datetime representations in string form (for example,
+from JSON APIs), you can convert them to universal datetimes easily:
+
+ >>> import time, times
+ >>> print times.to_universal('2012-02-03 11:59:03-0500') # auto-detects source timezone
+
+`Times` utilizes the string parsing routines available in [dateutil][3]. Note
+that the source timezone is auto-detected from the string. If the string
+contains a timezone offset, you are not allowed to explicitly specify one.
+
+If the string does not contain any timezone offset, you _must_ specify the
+source timezone explicitly:
+
+ >>> print times.to_universal('2012-02-03 11:59:03', 'Europe/Amsterdam')
+
+This is the inverse of `times.format()`.
+
+
POSIX timestamps
----------------
If you prefer working with UNIX (POSIX) timestamps, you can convert them to
@@ -92,3 +112,6 @@ a timezone instance or a timezone string.
`to_local`). However, you probably shouldn't do it, unless you want to
`strftime()` the resulting local date multiple times. In any other case, you
are advised to use `times.format()` directly instead.
+
+[3]: http://labix.org/python-dateutil#head-c0e81a473b647dfa787dc11e8c69557ec2c3ecd2
+