|
| 1 | +# -*- coding: utf-8 -*- |
1 | 2 | """
|
2 | 3 | Examples of how to use parsedatetime with locale information provided.
|
3 | 4 |
|
|
34 | 35 | # print out the values from Constants to show how the locale information
|
35 | 36 | # is being used/stored internally
|
36 | 37 |
|
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 | + |
50 | 57 |
|
51 | 58 | result = p.parse("March 24th")
|
52 | 59 |
|
53 | 60 |
|
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 |
55 | 62 | # and to use the internal Spanish locale class
|
56 | 63 |
|
57 | 64 | c = pdt.Constants(localeID="es", usePyICU=False)
|
58 | 65 | p = pdt.Calendar(c)
|
59 | 66 |
|
60 | 67 | result = p.parse("Marzo 24")
|
61 |
| - |
|
0 commit comments