ParseTimeWithoutTimezone converts a string into a time value on the epoch day, dropping any timezone information. The returned time always has UTC location. Any specified timezone is inconsequential. Examples: - "now": parses to the local time of day (in the current timezone) - "01:09:15.511971" an
( now time.Time, mode ParseMode, s string, )
| 179 | // The dependsOnContext return value indicates if we had to consult the given |
| 180 | // `now` value (either for the time or the local timezone). |
| 181 | func ParseTimeWithoutTimezone( |
| 182 | now time.Time, mode ParseMode, s string, |
| 183 | ) (_ time.Time, dependsOnContext bool, _ error) { |
| 184 | fe := fieldExtract{ |
| 185 | currentTime: now, |
| 186 | required: timeRequiredFields, |
| 187 | wanted: timeFields, |
| 188 | } |
| 189 | |
| 190 | if err := fe.Extract(s); err != nil { |
| 191 | // It's possible that the user has given us a complete |
| 192 | // timestamp string; let's try again, accepting more fields. |
| 193 | fe = fieldExtract{ |
| 194 | currentTime: now, |
| 195 | mode: mode, |
| 196 | required: timeRequiredFields, |
| 197 | wanted: dateTimeFields, |
| 198 | } |
| 199 | |
| 200 | if err := fe.Extract(s); err != nil { |
| 201 | return TimeEpoch, false, parseError(err, "time", s) |
| 202 | } |
| 203 | } |
| 204 | res := fe.MakeTimeWithoutTimezone() |
| 205 | return res, fe.currentTimeUsed, nil |
| 206 | } |
| 207 | |
| 208 | // ParseTimestamp converts a string into a timestamp. |
| 209 | // |
no test coverage detected