Skip to content

Commit 59229fe

Browse files
committed
Improves Windows support.
1 parent ead2d0f commit 59229fe

File tree

7 files changed

+21
-9
lines changed

7 files changed

+21
-9
lines changed

pendulum/date.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def day_of_week(self):
127127

128128
@property
129129
def day_of_year(self):
130-
return int(self.format('%-j', formatter='classic'))
130+
return int(self.format('%j', formatter='classic'))
131131

132132
@property
133133
def week_of_year(self):

pendulum/pendulum.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,7 @@ def to_day_datetime_string(self):
773773
774774
:rtype: str
775775
"""
776-
return self.format('%a, %b %d, %Y %-I:%M %p', formatter='classic')
776+
return self.format('ddd, MMM D, YYYY h:mm A', formatter='alternative')
777777

778778
def to_atom_string(self):
779779
"""

tests/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import sys
44
import pendulum
5+
import struct
56

67
from unittest import TestCase
78
from contextlib import contextmanager
@@ -115,3 +116,7 @@ def skip_if_not_36(self):
115116
def skip_if_36(self):
116117
if PY36:
117118
self.skipTest('Tests only available for Python <= 3.5')
119+
120+
def skip_if_32bit(self):
121+
if struct.calcsize("P") * 8 == 32:
122+
self.skipTest('Tests only available for 64bit systems')

tests/date_tests/test_strings.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def test_custom_formatters(self):
3333
d = Date(1975, 12, 25)
3434
self.assertEqual(
3535
'Thursday 25th of December 1975',
36-
d.format('%A %-d%_t of %B %Y')
36+
d.format('%A %d%_t of %B %Y')
3737
)
3838

3939
def test_repr(self):
@@ -44,7 +44,7 @@ def test_repr(self):
4444
def test_format_with_locale(self):
4545
d = Date(1975, 12, 25)
4646
self.assertEqual('jeudi 25e jour de décembre 1975',
47-
d.format('%A %-d%_t jour de %B %Y', locale='fr'))
47+
d.format('%A %d%_t jour de %B %Y', locale='fr'))
4848

4949
def test_set_formatter_globally(self):
5050
Date.set_formatter('alternative')

tests/formatting_tests/test_classic_formatter.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ def test_custom_formatters(self):
1313
f = ClassicFormatter()
1414
self.assertEqual(
1515
'Thursday 25th of December 1975 02:15:16 PM -05:00',
16-
f.format(d, '%A %-d%_t of %B %Y %I:%M:%S %p %_z')
16+
f.format(d, '%A %d%_t of %B %Y %I:%M:%S %p %_z')
1717
)
1818

1919
def test_format_with_locale(self):
2020
d = Pendulum(1975, 12, 25, 14, 15, 16, tzinfo='Europe/Paris')
2121
f = ClassicFormatter()
2222
self.assertEqual(
2323
'jeudi 25e jour de décembre 1975 02:15:16 +01:00',
24-
f.format(d, '%A %-d%_t jour de %B %Y %I:%M:%S %p %_z', locale='fr')
24+
f.format(d, '%A %d%_t jour de %B %Y %I:%M:%S %p %_z', locale='fr')
2525
)
2626

2727
def test_unlocalizable_directive(self):
@@ -61,5 +61,5 @@ def test_accepts_dates(self):
6161
f = ClassicFormatter()
6262
self.assertEqual(
6363
'Thursday 25th of December 1975',
64-
f.format(d, '%A %-d%_t of %B %Y')
64+
f.format(d, '%A %d%_t of %B %Y')
6565
)

tests/pendulum_tests/test_getters.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ def test_timestamp(self):
6464
self.assertEqual(60, d.add(minutes=1, microseconds=123456).timestamp)
6565

6666
def test_timestamp_accuracy(self):
67+
self.skip_if_32bit()
68+
6769
d = Pendulum(3000, 10, 1, 12, 23, 10, 999999)
6870

6971
self.assertEqual(32527311790, d.timestamp)
@@ -78,6 +80,8 @@ def test_int_timestamp(self):
7880
self.assertEqual(60, d.add(minutes=1, microseconds=123456).int_timestamp)
7981

8082
def test_int_timestamp_accuracy(self):
83+
self.skip_if_32bit()
84+
8185
d = Pendulum(3000, 10, 1, 12, 23, 10, 999999)
8286

8387
self.assertEqual(32527311790, d.int_timestamp)

tests/pendulum_tests/test_strings.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,10 @@ def test_to_w3c_string(self):
102102

103103
def test_custom_formatters(self):
104104
d = Pendulum(1975, 12, 25, 14, 15, 16, tzinfo='local')
105-
self.assertEqual('Thursday 25th of December 1975 02:15:16 PM -05:00', d.format('%A %-d%_t of %B %Y %I:%M:%S %p %_z'))
105+
self.assertEqual(
106+
'Thursday 25th of December 1975 02:15:16 PM -05:00',
107+
d.format('%A %d%_t of %B %Y %I:%M:%S %p %_z')
108+
)
106109

107110
def test_repr(self):
108111
d = Pendulum(1975, 12, 25, 14, 15, 16, tzinfo='local')
@@ -111,7 +114,7 @@ def test_repr(self):
111114
def test_format_with_locale(self):
112115
d = Pendulum(1975, 12, 25, 14, 15, 16, tzinfo='local')
113116
self.assertEqual('jeudi 25e jour de décembre 1975 02:15:16 -05:00',
114-
d.format('%A %-d%_t jour de %B %Y %I:%M:%S %p %_z', locale='fr'))
117+
d.format('%A %d%_t jour de %B %Y %I:%M:%S %p %_z', locale='fr'))
115118

116119
def test_set_formatter_globally(self):
117120
pendulum.Pendulum.set_formatter('alternative')

0 commit comments

Comments
 (0)