Skip to content

Commit df4d10f

Browse files
committed
Merge branch 'master' into 356-altendky-nth_of_month_outside_scope
2 parents caa8a94 + bc32743 commit df4d10f

File tree

20 files changed

+719
-41
lines changed

20 files changed

+719
-41
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ install:
6666
source "$HOME/virtualenvs/pypy-$PYPY_VERSION/bin/activate"
6767
fi
6868
- pip install pip -U
69-
- curl -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py | python
69+
- curl -fsS -o get-poetry.py https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py
70+
- python get-poetry.py --preview -y
7071
- source $HOME/.poetry/env
7172
- poetry install -v
7273
- poetry build -v

CHANGELOG.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
# Change Log
22

3-
## [Unreleased]
3+
## [2.0.5] - 2019-07-03
44

55
### Fixed
66

7-
- Fixed ISO week dates not being parsed properly in `fom_format()`.
7+
- Fixed ISO week dates not being parsed properly in `from_format()`.
8+
- Fixed loading of some timezones with empty posix spec.
9+
- Fixed deprecation warnings.
10+
11+
### Locales
12+
13+
- Added RU locale.
814

915

1016
## [2.0.4] - 2018-10-30
@@ -87,7 +93,8 @@
8793

8894

8995

90-
[Unreleased]: https://github.com/sdispater/pendulum/compare/2.0.4...master
96+
[Unreleased]: https://github.com/sdispater/pendulum/compare/2.0.5...master
97+
[2.0.5]: https://github.com/sdispater/pendulum/releases/tag/2.0.5
9198
[2.0.4]: https://github.com/sdispater/pendulum/releases/tag/2.0.4
9299
[2.0.3]: https://github.com/sdispater/pendulum/releases/tag/2.0.3
93100
[2.0.2]: https://github.com/sdispater/pendulum/releases/tag/2.0.2

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ If the locale does not exist you will need to create it by using the ``clock`` u
203203

204204
.. code-block:: bash
205205
206-
./clock locale:create <your-locale>
206+
./clock locale create <your-locale>
207207
208208
It will generate a directory in ``pendulum/locales`` named after your locale, with the following
209209
structure:

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ install:
2020
- "python -m pip install --disable-pip-version-check --user --upgrade pip"
2121

2222
# Downloading and installing poetry
23-
- python -m pip install poetry -U
23+
- python -m pip install poetry>=1.0.0b1 -U
2424

2525
# Install dependencies
2626
- python -m pip install codecov

clock

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ from babel.dates import tokenize_pattern, PATTERN_CHARS
1717
from babel.localedata import load, normalize_locale, LocaleDataDict
1818

1919
from cleo import Application, Command
20+
from cleo import argument
2021
from pendulum import __version__
2122

2223

@@ -43,12 +44,11 @@ class _LambdaCompiler(_GettextCompiler):
4344

4445

4546
class LocaleCreate(Command):
46-
"""
47-
Creates locale translations.
4847

49-
locale:create
50-
{locales?* : Locales to dump}
51-
"""
48+
name = "create"
49+
description = "Creates locale translations."
50+
51+
arguments = [argument("locales", "Locales to dump.", optional=False, multiple=True)]
5252

5353
TEMPLATE = """# -*- coding: utf-8 -*-
5454
from __future__ import unicode_literals
@@ -93,7 +93,7 @@ translations = {{}}
9393

9494
normalized = normalize_locale(locale.replace("-", "_"))
9595
if not normalized:
96-
self.error("Locale [{}] does not exist.".format(locale))
96+
self.line("<error>Locale [{}] does not exist.</error>".format(locale))
9797
continue
9898

9999
self.line("<info>Generating <comment>{}</> locale.</>".format(locale))
@@ -229,11 +229,9 @@ translations = {{}}
229229

230230

231231
class LocaleRecreate(Command):
232-
"""
233-
Recreate existing locales.
234232

235-
locale:recreate
236-
"""
233+
name = "recreate"
234+
description = "Recreate existing locales."
237235

238236
def handle(self):
239237
# Listing locales
@@ -245,12 +243,21 @@ class LocaleRecreate(Command):
245243
self.call("locale:create", [("locales", locales)])
246244

247245

246+
class LocaleCommand(Command):
247+
248+
name = "locale"
249+
description = "Locale related commands."
250+
251+
commands = [LocaleCreate()]
252+
253+
def handle(self):
254+
self.call("help", self._config.name)
255+
256+
248257
class WindowsTzDump(Command):
249-
"""
250-
Dumps the mapping of Windows timezones to IANA timezones.
251258

252-
windows:tz:dump
253-
"""
259+
name = "dump-timezones"
260+
description = "Dumps the mapping of Windows timezones to IANA timezones."
254261

255262
MAPPING_DIR = os.path.join("pendulum", "tz", "data")
256263

@@ -269,10 +276,20 @@ class WindowsTzDump(Command):
269276
f.write(mapping)
270277

271278

272-
app = Application("Clock", __version__)
273-
app.add(LocaleCreate())
274-
app.add(LocaleRecreate())
275-
app.add(WindowsTzDump())
279+
class WindowsCommand(Command):
280+
281+
name = "windows"
282+
description = "Windows related commands."
283+
284+
commands = [WindowsTzDump()]
285+
286+
def handle(self):
287+
self.call("help", self._config.name)
288+
289+
290+
app = Application("clock", __version__)
291+
app.add(LocaleCommand())
292+
app.add(WindowsCommand())
276293

277294

278295
if __name__ == "__main__":

pendulum/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "2.0.4"
1+
__version__ = "2.0.5"

pendulum/formatting/formatter.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
_MATCH_5_TO_6 = "\d{5}\d?"
2626
_MATCH_UNSIGNED = "\d+"
2727
_MATCH_SIGNED = "[+-]?\d+"
28-
_MATCH_OFFSET = "(?i)Z|[+-]\d\d:?\d\d"
29-
_MATCH_SHORT_OFFSET = "(?i)Z|[+-]\d\d(?::?\d\d)?"
28+
_MATCH_OFFSET = "[Zz]|[+-]\d\d:?\d\d"
29+
_MATCH_SHORT_OFFSET = "[Zz]|[+-]\d\d(?::?\d\d)?"
3030
_MATCH_TIMESTAMP = "[+-]?\d+(\.\d{1,6})?"
3131
_MATCH_WORD = (
3232
"(?i)[0-9]*"
@@ -403,7 +403,7 @@ def parse(
403403
lambda m: self._replace_tokens(m.group(0), locale), escaped_fmt
404404
)
405405

406-
if not re.match(pattern, time):
406+
if not re.search("^" + pattern + "$", time):
407407
raise ValueError("String does not match format {}".format(fmt))
408408

409409
re.sub(pattern, lambda m: self._get_parsed_values(m, parsed, locale, now), time)

pendulum/locales/id/__init__.py

Whitespace-only changes.

pendulum/locales/id/custom.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# -*- coding: utf-8 -*-
2+
from __future__ import unicode_literals
3+
4+
"""
5+
id custom locale file.
6+
"""
7+
8+
translations = {
9+
"units": {"few_second": "beberapa detik"},
10+
"ago": "{} yang lalu",
11+
"from_now": "dalam {}",
12+
"after": "{0} kemudian",
13+
"before": "{0} yang lalu",
14+
"date_formats": {
15+
"LTS": "HH:mm:ss",
16+
"LT": "HH:mm",
17+
"LLLL": "dddd [d.] D. MMMM YYYY HH:mm",
18+
"LLL": "D. MMMM YYYY HH:mm",
19+
"LL": "D. MMMM YYYY",
20+
"L": "DD/MM/YYYY",
21+
},
22+
}

pendulum/locales/id/locale.py

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
# -*- coding: utf-8 -*-
2+
from __future__ import unicode_literals
3+
4+
"""
5+
id locale file.
6+
7+
It has been generated automatically and must not be modified directly.
8+
"""
9+
10+
from .custom import translations as custom_translations
11+
12+
13+
locale = {
14+
"plural": lambda n: "other",
15+
"ordinal": lambda n: "other",
16+
"translations": {
17+
"days": {
18+
"abbreviated": {
19+
0: "Min",
20+
1: "Sen",
21+
2: "Sel",
22+
3: "Rab",
23+
4: "Kam",
24+
5: "Jum",
25+
6: "Sab",
26+
},
27+
"narrow": {0: "M", 1: "S", 2: "S", 3: "R", 4: "K", 5: "J", 6: "S"},
28+
"short": {
29+
0: "Min",
30+
1: "Sen",
31+
2: "Sel",
32+
3: "Rab",
33+
4: "Kam",
34+
5: "Jum",
35+
6: "Sab",
36+
},
37+
"wide": {
38+
0: "Minggu",
39+
1: "Senin",
40+
2: "Selasa",
41+
3: "Rabu",
42+
4: "Kamis",
43+
5: "Jumat",
44+
6: "Sabtu",
45+
},
46+
},
47+
"months": {
48+
"abbreviated": {
49+
1: "Jan",
50+
2: "Feb",
51+
3: "Mar",
52+
4: "Apr",
53+
5: "Mei",
54+
6: "Jun",
55+
7: "Jul",
56+
8: "Agt",
57+
9: "Sep",
58+
10: "Okt",
59+
11: "Nov",
60+
12: "Des",
61+
},
62+
"narrow": {
63+
1: "J",
64+
2: "F",
65+
3: "M",
66+
4: "A",
67+
5: "M",
68+
6: "J",
69+
7: "J",
70+
8: "A",
71+
9: "S",
72+
10: "O",
73+
11: "N",
74+
12: "D",
75+
},
76+
"wide": {
77+
1: "Januari",
78+
2: "Februari",
79+
3: "Maret",
80+
4: "April",
81+
5: "Mei",
82+
6: "Juni",
83+
7: "Juli",
84+
8: "Agustus",
85+
9: "September",
86+
10: "Oktober",
87+
11: "November",
88+
12: "Desember",
89+
},
90+
},
91+
"units": {
92+
"year": {"other": "{0} tahun"},
93+
"month": {"other": "{0} bulan"},
94+
"week": {"other": "{0} minggu"},
95+
"day": {"other": "{0} hari"},
96+
"hour": {"other": "{0} jam"},
97+
"minute": {"other": "{0} menit"},
98+
"second": {"other": "{0} detik"},
99+
"microsecond": {"other": "{0} mikrodetik"},
100+
},
101+
"relative": {
102+
"year": {
103+
"future": {"other": "dalam {0} tahun"},
104+
"past": {"other": "{0} tahun yang lalu"},
105+
},
106+
"month": {
107+
"future": {"other": "dalam {0} bulan"},
108+
"past": {"other": "{0} bulan yang lalu"},
109+
},
110+
"week": {
111+
"future": {"other": "dalam {0} minggu"},
112+
"past": {"other": "{0} minggu yang lalu"},
113+
},
114+
"day": {
115+
"future": {"other": "dalam {0} hari"},
116+
"past": {"other": "{0} hari yang lalu"},
117+
},
118+
"hour": {
119+
"future": {"other": "dalam {0} jam"},
120+
"past": {"other": "{0} jam yang lalu"},
121+
},
122+
"minute": {
123+
"future": {"other": "dalam {0} menit"},
124+
"past": {"other": "{0} menit yang lalu"},
125+
},
126+
"second": {
127+
"future": {"other": "dalam {0} detik"},
128+
"past": {"other": "{0} detik yang lalu"},
129+
},
130+
},
131+
"day_periods": {
132+
"midnight": "tengah malam",
133+
"am": "AM",
134+
"noon": "tengah hari",
135+
"pm": "PM",
136+
"morning1": "pagi",
137+
"afternoon1": "siang",
138+
"evening1": "sore",
139+
"night1": "malam",
140+
},
141+
},
142+
"custom": custom_translations,
143+
}

0 commit comments

Comments
 (0)