diff doc/formatting.txt @ 34:3666f3d3df15

Extended time-zone support.
author cmlenz
date Mon, 04 Jun 2007 16:03:12 +0000
parents 48cf004aa357
children b6c51490cc95
line wrap: on
line diff
--- a/doc/formatting.txt
+++ b/doc/formatting.txt
@@ -208,21 +208,26 @@
 reliably converting from UTC to local time, and vice versa::
 
     >>> from datetime import time
-    >>> t = time(15, 30)
-    
-    >>> from pytz import timezone
-    >>> cet = timezone('Europe/Berlin')
-    >>> format_time(t, 'H:mm Z', tzinfo=cet, locale='de_DE')
-    u'15:30 +0100'
+    >>> from pytz import timezone, utc
+    >>> dt = datetime(2007, 04, 01, 15, 30, tzinfo=utc)
+    >>> eastern = timezone('US/Eastern')
+    >>> format_datetime(dt, 'H:mm Z', tzinfo=eastern, locale='en_US')
+    u'11:30 -0400'
 
 The recommended approach to deal with different time-zones in a Python
 application is to always use UTC internally, and only convert from/to the users
 time-zone when accepting user input and displaying date/time data, respectively.
+You can use Babel together with ``pytz`` to apply a time-zone to any
+``datetime`` or ``time`` object for display, leaving the original information
+unchanged::
+
+    >>> british = timezone('Europe/London')
+    >>> format_datetime(dt, 'H:mm zzzz', tzinfo=british, locale='en_US')
+    u'16:30 British Summer Time'
 
  .. _`pytz`: http://pytz.sourceforge.net/
 
 
-
 Parsing Dates
 -------------
 
@@ -309,7 +314,7 @@
 
 Babel can also parse numeric data in a locale-sensitive manner::
 
-    >>> from babel.dates import parse_decimal, parse_number
+    >>> from babel.numbers import parse_decimal, parse_number
 
 Examples::
 
Copyright (C) 2012-2017 Edgewall Software