MCPcopy
hub / github.com/pelletier/go-toml / parseLocalDateTime

Function parseLocalDateTime

decode.go:434–460  ·  view source on GitHub ↗

parseLocalDateTime parses a local date time of the form YYYY-MM-DD(T| )HH:MM:SS[.NNNNNN]. It returns the remaining bytes after the date-time.

(b []byte)

Source from the content-addressed store, hash-verified

432// YYYY-MM-DD(T| )HH:MM:SS[.NNNNNN]. It returns the remaining bytes after the
433// date-time.
434func parseLocalDateTime(b []byte) (LocalDateTime, []byte, error) {
435 var dt LocalDateTime
436
437 const localDateTimeByteMinLen = 11
438 if len(b) < localDateTimeByteMinLen {
439 return dt, nil, unstable.NewParserError(b, "local datetimes are expected to have the format YYYY-MM-DDTHH:MM[:SS[.NNNNNNNNN]]")
440 }
441
442 date, err := parseLocalDate(b[:10])
443 if err != nil {
444 return dt, nil, err
445 }
446 dt.LocalDate = date
447
448 sep := b[10]
449 if sep != 'T' && sep != ' ' && sep != 't' {
450 return dt, nil, unstable.NewParserError(b[10:11], "datetime separator is expected to be T or a space")
451 }
452
453 t, rest, err := parseLocalTime(b[11:])
454 if err != nil {
455 return dt, nil, err
456 }
457 dt.LocalTime = t
458
459 return dt, rest, nil
460}
461
462// parseDateTime parses a date-time with a timezone offset (Z or +/-HH:MM).
463func parseDateTime(b []byte) (time.Time, error) {

Callers 6

fusedScalarMethod · 0.85
UnmarshalTextMethod · 0.85
assignLocalDateTimeMethod · 0.85
decodeAnyMethod · 0.85
parseDateTimeFunction · 0.85

Calls 3

NewParserErrorFunction · 0.92
parseLocalDateFunction · 0.85
parseLocalTimeFunction · 0.85

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…