Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/arrow/constants.py: 100%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

13 statements  

1"""Constants used internally in arrow.""" 

2 

3import sys 

4from datetime import datetime 

5from typing import Final 

6 

7# datetime.max.timestamp() errors on Windows, so we must hardcode 

8# the highest possible datetime value that can output a timestamp. 

9# tl;dr platform-independent max timestamps are hard to form 

10# See: https://stackoverflow.com/q/46133223 

11try: 

12 # Get max timestamp. Works on POSIX-based systems like Linux and macOS, 

13 # but will trigger an OverflowError, ValueError, or OSError on Windows 

14 _MAX_TIMESTAMP = datetime.max.timestamp() 

15except (OverflowError, ValueError, OSError): # pragma: no cover 

16 # Fallback for Windows and 32-bit systems if initial max timestamp call fails 

17 # Must get max value of ctime on Windows based on architecture (x32 vs x64) 

18 # https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/ctime-ctime32-ctime64-wctime-wctime32-wctime64 

19 # Note: this may occur on both 32-bit Linux systems (issue #930) along with Windows systems 

20 is_64bits = sys.maxsize > 2**32 

21 _MAX_TIMESTAMP = ( 

22 datetime(3000, 1, 1, 23, 59, 59, 999999).timestamp() 

23 if is_64bits 

24 else datetime(2038, 1, 1, 23, 59, 59, 999999).timestamp() 

25 ) 

26 

27MAX_TIMESTAMP: Final[float] = _MAX_TIMESTAMP 

28MAX_TIMESTAMP_MS: Final[float] = MAX_TIMESTAMP * 1000 

29MAX_TIMESTAMP_US: Final[float] = MAX_TIMESTAMP * 1_000_000 

30 

31MAX_ORDINAL: Final[int] = datetime.max.toordinal() 

32MIN_ORDINAL: Final[int] = 1 

33 

34DEFAULT_LOCALE: Final[str] = "en-us" 

35 

36# Supported dehumanize locales 

37DEHUMANIZE_LOCALES = { 

38 "en", 

39 "en-us", 

40 "en-gb", 

41 "en-au", 

42 "en-be", 

43 "en-jp", 

44 "en-za", 

45 "en-ca", 

46 "en-ph", 

47 "fr", 

48 "fr-fr", 

49 "fr-ca", 

50 "it", 

51 "it-it", 

52 "es", 

53 "es-es", 

54 "el", 

55 "el-gr", 

56 "ja", 

57 "ja-jp", 

58 "se", 

59 "se-fi", 

60 "se-no", 

61 "se-se", 

62 "sv", 

63 "sv-se", 

64 "fi", 

65 "fi-fi", 

66 "zh", 

67 "zh-cn", 

68 "zh-tw", 

69 "zh-hk", 

70 "nl", 

71 "nl-nl", 

72 "be", 

73 "be-by", 

74 "pl", 

75 "pl-pl", 

76 "ru", 

77 "ru-ru", 

78 "af", 

79 "bg", 

80 "bg-bg", 

81 "ua", 

82 "uk", 

83 "uk-ua", 

84 "mk", 

85 "mk-mk", 

86 "de", 

87 "de-de", 

88 "de-ch", 

89 "de-at", 

90 "nb", 

91 "nb-no", 

92 "nn", 

93 "nn-no", 

94 "pt", 

95 "pt-pt", 

96 "pt-br", 

97 "tl", 

98 "tl-ph", 

99 "vi", 

100 "vi-vn", 

101 "tr", 

102 "tr-tr", 

103 "az", 

104 "az-az", 

105 "da", 

106 "da-dk", 

107 "ml", 

108 "hi", 

109 "cs", 

110 "cs-cz", 

111 "sk", 

112 "sk-sk", 

113 "fa", 

114 "fa-ir", 

115 "mr", 

116 "ca", 

117 "ca-es", 

118 "ca-ad", 

119 "ca-fr", 

120 "ca-it", 

121 "eo", 

122 "eo-xx", 

123 "bn", 

124 "bn-bd", 

125 "bn-in", 

126 "rm", 

127 "rm-ch", 

128 "ro", 

129 "ro-ro", 

130 "sl", 

131 "sl-si", 

132 "id", 

133 "id-id", 

134 "ne", 

135 "ne-np", 

136 "ee", 

137 "et", 

138 "sw", 

139 "sw-ke", 

140 "sw-tz", 

141 "la", 

142 "la-va", 

143 "lt", 

144 "lt-lt", 

145 "ms", 

146 "ms-my", 

147 "ms-bn", 

148 "or", 

149 "or-in", 

150 "lb", 

151 "lb-lu", 

152 "zu", 

153 "zu-za", 

154 "sq", 

155 "sq-al", 

156 "ta", 

157 "ta-in", 

158 "ta-lk", 

159 "ur", 

160 "ur-pk", 

161 "ka", 

162 "ka-ge", 

163 "kk", 

164 "kk-kz", 

165 # "lo", 

166 # "lo-la", 

167 "am", 

168 "am-et", 

169 "hy-am", 

170 "hy", 

171 "uz", 

172 "uz-uz", 

173}