Skip to content

Commit 54550dd

Browse files
committed
Added support for ixt-sec:durmonth
1 parent 838cfdf commit 54550dd

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

tests/test_transformation.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,9 @@
149149
['duryear', '21.84480', 'P21Y10M5D'],
150150
['duryear', '+0.3456', 'P0Y4M4D'],
151151

152+
['durmonth', '22.3456', 'P22M10D'],
153+
['durmonth', '-0.3456', '-P0M10D'],
154+
152155
['durwordsen', 'Five years, two months', 'P5Y2M0D'],
153156
['durwordsen', '9 years, 2 months', 'P9Y2M0D'],
154157
['durwordsen', '12 days', 'P0Y0M12D'],

xbrl/transformations/__init__.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,15 @@ def durYear(arg: str) -> str:
285285
return f"{'P' if pos else '-P'}{fullYears}Y{fullMonths}M{remainingDays}D"
286286

287287

288+
def durMonth(arg: str) -> str:
289+
# 22.3456 -> P22M10D (Period: 22 Months, 10 Days)
290+
pos: bool = float(arg) >= 0
291+
monthDec: float = abs(float(arg))
292+
fullMonths: int = floor(abs(monthDec))
293+
remainingDays: int = round((monthDec - fullMonths) * 30)
294+
return f"{'P' if pos else '-P'}{fullMonths}M{remainingDays}D"
295+
296+
288297
def durWordSen(arg: str) -> str:
289298
value = replace_text_numbers(arg)
290299
years, months, days = 0, 0, 0
@@ -480,7 +489,7 @@ def stateNameEN(arg: str) -> str:
480489
# As defined in https://www.sec.gov/info/edgar/specifications/edgarfm-vol2-v59.pdf
481490
ixt_sec = {
482491
'duryear': durYear,
483-
'durmonth': notImplemented,
492+
'durmonth': durMonth,
484493
'durweek': notImplemented,
485494
'durday': notImplemented,
486495
'durhour': notImplemented,

0 commit comments

Comments
 (0)