* Provides a string length to use for converting datetime * objects with the given local and unit settings. */
| 757 | * objects with the given local and unit settings. |
| 758 | */ |
| 759 | NPY_NO_EXPORT int |
| 760 | get_datetime_iso_8601_strlen(int local, NPY_DATETIMEUNIT base) |
| 761 | { |
| 762 | int len = 0; |
| 763 | |
| 764 | switch (base) { |
| 765 | case NPY_FR_ERROR: |
| 766 | /* If no unit is provided, return the maximum length */ |
| 767 | return NPY_DATETIME_MAX_ISO8601_STRLEN; |
| 768 | case NPY_FR_GENERIC: |
| 769 | /* Generic units can only be used to represent NaT */ |
| 770 | return 4; |
| 771 | case NPY_FR_as: |
| 772 | len += 3; /* "###" */ |
| 773 | case NPY_FR_fs: |
| 774 | len += 3; /* "###" */ |
| 775 | case NPY_FR_ps: |
| 776 | len += 3; /* "###" */ |
| 777 | case NPY_FR_ns: |
| 778 | len += 3; /* "###" */ |
| 779 | case NPY_FR_us: |
| 780 | len += 3; /* "###" */ |
| 781 | case NPY_FR_ms: |
| 782 | len += 4; /* ".###" */ |
| 783 | case NPY_FR_s: |
| 784 | len += 3; /* ":##" */ |
| 785 | case NPY_FR_m: |
| 786 | len += 3; /* ":##" */ |
| 787 | case NPY_FR_h: |
| 788 | len += 3; /* "T##" */ |
| 789 | case NPY_FR_D: |
| 790 | case NPY_FR_W: |
| 791 | len += 3; /* "-##" */ |
| 792 | case NPY_FR_M: |
| 793 | len += 3; /* "-##" */ |
| 794 | case NPY_FR_Y: |
| 795 | len += 21; /* 64-bit year */ |
| 796 | break; |
| 797 | } |
| 798 | |
| 799 | if (base >= NPY_FR_h) { |
| 800 | if (local) { |
| 801 | len += 5; /* "+####" or "-####" */ |
| 802 | } |
| 803 | else { |
| 804 | len += 1; /* "Z" */ |
| 805 | } |
| 806 | } |
| 807 | |
| 808 | len += 1; /* NULL terminator */ |
| 809 | |
| 810 | return len; |
| 811 | } |
| 812 | |
| 813 | /* |
| 814 | * Finds the largest unit whose value is nonzero, and for which |
no outgoing calls
no test coverage detected