Instance validation exception: month must be in 1..12

122 views
Skip to first unread message

Pavel Malafeev

unread,
Nov 8, 2017, 5:53:42 PM11/8/17
to Arelle-users
I'm trying to view xbrl taxonomy http://cbr.ru/Content/Document/File/27768/final_0_8_0.zip and getting Instance validation exception: month must be in 1..12. The stack trace is below.
I've done some debugging and found that exception is caused by the subtract operation 2017-12-31 minus P2Y0M in addYearMonthDuration.

I'd like to propose a following fix for this issue (changes are marked with yellow):
    def addYearMonthDuration(self, other, sign):
        m = self.month + sign * other.months
        y = self.year + sign * other.years + (m - 1) // 12
        m %= 12
        if not m: m = 12
        d = self.day
        lastDay = lastDayOfMonth(y, m)
        if d > lastDay: d = lastDay
        return DateTime(y, m, d, self.hour, self.minute, self.second, self.microsecond, self.tzinfo, self.dateOnly)


[exception:ValueError] Instance validation exception: month must be in 1..12, instance: ep_nso_purcb_m_30d.xsd - ep_nso_purcb_m_30d.xsd 
Traceback (most recent call last):
  File "Z:\Users\arelle\hfdev\arelle\Validate.py", line 108, in validate
  File "Z:\Users\arelle\hfdev\arelle\ValidateXbrl.py", line 511, in validate
  File "Z:\Users\arelle\hfdev\arelle\ValidateFormula.py", line 403, in validate
  File "Z:\Users\arelle\hfdev\arelle\ModelFormulaObject.py", line 670, in evaluate
  File "Z:\Users\arelle\hfdev\arelle\XPathContext.py", line 440, in evaluateAtomicValue
  File "Z:\Users\arelle\hfdev\arelle\XPathContext.py", line 228, in evaluate
  File "Z:\Users\arelle\hfdev\arelle\ModelValue.py", line 303, in __sub__
  File "Z:\Users\arelle\hfdev\arelle\ModelValue.py", line 292, in addYearMonthDuration
  File "Z:\Users\arelle\hfdev\arelle\ModelValue.py", line 264, in __new__
ValueError: month must be in 1..12

Herm Fischer

unread,
Nov 22, 2017, 12:25:51 AM11/22/17
to arelle...@googlegroups.com, storn...@gmail.com
Pavel,

I think this would cover more situations, please check:

        m = self.month + sign * other.months - 1 # m is zero based now (0 - Jan, 11 - Dec)
        y = self.year + sign * other.years + m // 12
        m = (m % 12) + 1 # m back to 1 based (1 = Jan)

Herm Fischer

--

---
You received this message because you are subscribed to the Google Groups "Arelle-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to arelle-users...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages