@@ -33,55 +33,6 @@ This file implements string parsing and creation for NumPy datetime.
33
33
#include "np_datetime_strings.h"
34
34
35
35
36
- /* Platform-specific time_t typedef */
37
- typedef time_t NPY_TIME_T ;
38
-
39
- /*
40
- * Wraps `localtime` functionality for multiple platforms. This
41
- * converts a time value to a time structure in the local timezone.
42
- *
43
- * Returns 0 on success, -1 on failure.
44
- */
45
- static int get_localtime (NPY_TIME_T * ts , struct tm * tms ) {
46
- char * func_name = "<unknown>" ;
47
- #if defined(_WIN32 )
48
- #if defined(_MSC_VER ) && (_MSC_VER >= 1400 )
49
- if (localtime_s (tms , ts ) != 0 ) {
50
- func_name = "localtime_s" ;
51
- goto fail ;
52
- }
53
- #elif defined(__GNUC__ ) && defined(NPY_MINGW_USE_CUSTOM_MSVCR )
54
- if (_localtime64_s (tms , ts ) != 0 ) {
55
- func_name = "_localtime64_s" ;
56
- goto fail ;
57
- }
58
- #else
59
- struct tm * tms_tmp ;
60
- localtime_r (ts , tms_tmp );
61
- if (tms_tmp == NULL ) {
62
- func_name = "localtime" ;
63
- goto fail ;
64
- }
65
- memcpy (tms , tms_tmp , sizeof (struct tm ));
66
- #endif
67
- #else
68
- if (localtime_r (ts , tms ) == NULL ) {
69
- func_name = "localtime_r" ;
70
- goto fail ;
71
- }
72
- #endif
73
-
74
- return 0 ;
75
-
76
- fail :
77
- PyErr_Format (PyExc_OSError ,
78
- "Failed to use '%s' to convert "
79
- "to a local time" ,
80
- func_name );
81
- return -1 ;
82
- }
83
-
84
-
85
36
/*
86
37
* Parses (almost) standard ISO 8601 date strings. The differences are:
87
38
*
@@ -138,59 +89,6 @@ int parse_iso_8601_datetime(char *str, int len,
138
89
out -> month = 1 ;
139
90
out -> day = 1 ;
140
91
141
- /*
142
- * The string "today" means take today's date in local time, and
143
- * convert it to a date representation. This date representation, if
144
- * forced into a time unit, will be at midnight UTC.
145
- * This is perhaps a little weird, but done so that the
146
- * 'datetime64[D]' type produces the date you expect, rather than
147
- * switching to an adjacent day depending on the current time and your
148
- * timezone.
149
- */
150
- if (len == 5 && tolower (str [0 ]) == 't' && tolower (str [1 ]) == 'o' &&
151
- tolower (str [2 ]) == 'd' && tolower (str [3 ]) == 'a' &&
152
- tolower (str [4 ]) == 'y' ) {
153
- NPY_TIME_T rawtime = 0 ;
154
- struct tm tm_ ;
155
-
156
- time (& rawtime );
157
- if (get_localtime (& rawtime , & tm_ ) < 0 ) {
158
- return -1 ;
159
- }
160
- out -> year = tm_ .tm_year + 1900 ;
161
- out -> month = tm_ .tm_mon + 1 ;
162
- out -> day = tm_ .tm_mday ;
163
-
164
- /*
165
- * Indicate that this was a special value, and
166
- * is a date (unit 'D').
167
- */
168
- if (out_local != NULL ) {
169
- * out_local = 0 ;
170
- }
171
-
172
- return 0 ;
173
- }
174
-
175
- /* The string "now" resolves to the current UTC time */
176
- if (len == 3 && tolower (str [0 ]) == 'n' && tolower (str [1 ]) == 'o' &&
177
- tolower (str [2 ]) == 'w' ) {
178
- NPY_TIME_T rawtime = 0 ;
179
-
180
- time (& rawtime );
181
-
182
- /*
183
- * Indicate that this was a special value, and
184
- * use 's' because the time() function has resolution
185
- * seconds.
186
- */
187
- if (out_local != NULL ) {
188
- * out_local = 0 ;
189
- }
190
-
191
- return convert_datetime_to_datetimestruct (PANDAS_FR_s , rawtime , out );
192
- }
193
-
194
92
substr = str ;
195
93
sublen = len ;
196
94
0 commit comments