Skip to content

Commit 3fc165e

Browse files
author
Bernardo Sulzbach
committed
Now it works for Python 3.4.1
Some encoding declarations. Clearer and more efficient code (just 1 call to print). [Also compatible with Python 3 now] (I-think-it-is) A grammar error fixed.
1 parent c30018e commit 3fc165e

File tree

2 files changed

+22
-16
lines changed

2 files changed

+22
-16
lines changed

examples/with_locale.py

+21-15
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12
"""
23
Examples of how to use parsedatetime with locale information provided.
34
@@ -34,28 +35,33 @@
3435
# print out the values from Constants to show how the locale information
3536
# is being used/stored internally
3637

37-
print c.uses24, c.usesMeridian # 24hr clock? AM/PM used?
38-
print c.usePyICU # was PyICU found/enabled?
39-
print c.meridian # list of the am and pm values
40-
print c.am # list of the lowercased and stripped am string
41-
print c.pm # list of the lowercased and stripped pm string
42-
print c.dateFormats # dictionary of available date format strings
43-
print c.timeFormats # dictionary of available time format strings
44-
print c.timeSep # list of time separator, e.g. the ':' in '12:45'
45-
print c.dateSep # list of date serarator, e.g. the '/' in '11/23/2006'
46-
print c.Months # list of full month names
47-
print c.shortMonths # list of the short month names
48-
print c.Weekdays # list of the full week day names
49-
print c.localeID # the locale identifier
38+
values = (c.uses24, # 24hr clock?
39+
c.usesMeridian, # AM/PM used?
40+
c.usePyICU, # was PyICU found/enabled?
41+
c.meridian, # list of the am and pm values
42+
c.am, # list of the lowercase and stripped AM string
43+
c.pm, # list of the lowercase and stripped PM string
44+
c.dateFormats, # dict of available date format strings
45+
c.timeFormats, # dict of available time format strings
46+
c.timeSep, # list of time separator, e.g. the ':' in '12:45'
47+
c.dateSep, # list of date separator, e.g. the '/' in '11/23/2006'
48+
c.Months, # list of full month names
49+
c.shortMonths, # list of the short month names
50+
c.Weekdays, # list of the full week day names
51+
c.localeID # the locale identifier
52+
)
53+
54+
55+
print('\n'.join((str(value) for value in values)))
56+
5057

5158
result = p.parse("March 24th")
5259

5360

54-
# create an instance of Constants class and force it to no use PyICU
61+
# create an instance of Constants class and force it not to use PyICU
5562
# and to use the internal Spanish locale class
5663

5764
c = pdt.Constants(localeID="es", usePyICU=False)
5865
p = pdt.Calendar(c)
5966

6067
result = p.parse("Marzo 24")
61-

parsedatetime/pdt_locales.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1+
# -*- coding: utf-8 -*-
22
"""
33
pdt_locales
44

0 commit comments

Comments
 (0)