ParseTimestamp converts a string into a timestamp. The dependsOnContext return value indicates if we had to consult the given `now` value (either for the time or the local timezone).
( now time.Time, mode ParseMode, s string, )
| 210 | // The dependsOnContext return value indicates if we had to consult the given |
| 211 | // `now` value (either for the time or the local timezone). |
| 212 | func ParseTimestamp( |
| 213 | now time.Time, mode ParseMode, s string, |
| 214 | ) (_ time.Time, dependsOnContext bool, _ error) { |
| 215 | fe := fieldExtract{ |
| 216 | mode: mode, |
| 217 | currentTime: now, |
| 218 | // A timestamp only actually needs a date component; the time |
| 219 | // would be midnight. |
| 220 | required: dateRequiredFields, |
| 221 | wanted: dateTimeFields, |
| 222 | } |
| 223 | |
| 224 | if err := fe.Extract(s); err != nil { |
| 225 | return TimeEpoch, false, parseError(err, "timestamp", s) |
| 226 | } |
| 227 | res := fe.MakeTimestamp() |
| 228 | return res, fe.currentTimeUsed, nil |
| 229 | } |
| 230 | |
| 231 | // ParseTimestampWithoutTimezone converts a string into a timestamp, stripping |
| 232 | // away any timezone information. Any specified timezone is inconsequential. The |