Skip to content

Commit

Permalink
Now it works for Python 3.4.1
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Bernardo Sulzbach committed Jul 11, 2014
1 parent c30018e commit 3fc165e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
36 changes: 21 additions & 15 deletions examples/with_locale.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
"""
Examples of how to use parsedatetime with locale information provided.
Expand Down Expand Up @@ -34,28 +35,33 @@
# print out the values from Constants to show how the locale information
# is being used/stored internally

print c.uses24, c.usesMeridian # 24hr clock? AM/PM used?
print c.usePyICU # was PyICU found/enabled?
print c.meridian # list of the am and pm values
print c.am # list of the lowercased and stripped am string
print c.pm # list of the lowercased and stripped pm string
print c.dateFormats # dictionary of available date format strings
print c.timeFormats # dictionary of available time format strings
print c.timeSep # list of time separator, e.g. the ':' in '12:45'
print c.dateSep # list of date serarator, e.g. the '/' in '11/23/2006'
print c.Months # list of full month names
print c.shortMonths # list of the short month names
print c.Weekdays # list of the full week day names
print c.localeID # the locale identifier
values = (c.uses24, # 24hr clock?
c.usesMeridian, # AM/PM used?
c.usePyICU, # was PyICU found/enabled?
c.meridian, # list of the am and pm values
c.am, # list of the lowercase and stripped AM string
c.pm, # list of the lowercase and stripped PM string
c.dateFormats, # dict of available date format strings
c.timeFormats, # dict of available time format strings
c.timeSep, # list of time separator, e.g. the ':' in '12:45'
c.dateSep, # list of date separator, e.g. the '/' in '11/23/2006'
c.Months, # list of full month names
c.shortMonths, # list of the short month names
c.Weekdays, # list of the full week day names
c.localeID # the locale identifier
)


print('\n'.join((str(value) for value in values)))


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


# create an instance of Constants class and force it to no use PyICU
# create an instance of Constants class and force it not to use PyICU
# and to use the internal Spanish locale class

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

result = p.parse("Marzo 24")

2 changes: 1 addition & 1 deletion parsedatetime/pdt_locales.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

# -*- coding: utf-8 -*-
"""
pdt_locales
Expand Down

0 comments on commit 3fc165e

Please sign in to comment.