Skip to content

Commit 5f11316

Browse files
committed
BUG: test/fix to not always normalize with quarterly time rules, GH #1113
1 parent 1a35746 commit 5f11316

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

pandas/tseries/offsets.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,9 @@ def apply(self, other):
632632
other = other + relativedelta(months=3*n - monthsSince)
633633
wkday, _ = lib.monthrange(other.year, other.month)
634634
first = _get_firstbday(wkday)
635-
result = datetime(other.year, other.month, first)
635+
result = datetime(other.year, other.month, first,
636+
other.hour, other.minute, other.second,
637+
other.microsecond)
636638
return result
637639

638640
@property

pandas/tseries/tests/test_offsets.py

+9
Original file line numberDiff line numberDiff line change
@@ -1298,6 +1298,15 @@ def test_get_standard_freq():
12981298
assert fstr == get_standard_freq('5QuarTer')
12991299
assert fstr == get_standard_freq(('q', 5))
13001300

1301+
def test_quarterly_dont_normalize():
1302+
date = datetime(2012, 3, 31, 5, 30)
1303+
1304+
offsets = (QuarterBegin, QuarterEnd, BQuarterEnd, BQuarterBegin)
1305+
1306+
for klass in offsets:
1307+
result = date + klass()
1308+
assert(result.time() == date.time())
1309+
13011310
def test_rule_code():
13021311
lst = ['M', 'MS', 'BM', 'BMS', 'D', 'B', 'H', 'T', 'S', 'L', 'U']
13031312
for k in lst:

0 commit comments

Comments
 (0)