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

Method assignLocalTime

unmarshaler.go:1860–1881  ·  view source on GitHub ↗
(v reflect.Value, value *unstable.Node)

Source from the content-addressed store, hash-verified

1858}
1859
1860func (d *decoder) assignLocalTime(v reflect.Value, value *unstable.Node) (reflect.Value, error) {
1861 t, rest, err := parseLocalTime(value.Data)
1862 if err != nil {
1863 return reflect.Value{}, err
1864 }
1865 if len(rest) > 0 {
1866 return reflect.Value{}, unstable.NewParserError(rest, "extra characters at the end of a local time")
1867 }
1868
1869 switch v.Type() {
1870 case localTimeType:
1871 v.Set(reflect.ValueOf(t))
1872 return v, nil
1873 case timeType:
1874 v.Set(reflect.ValueOf(time.Date(0, 1, 1, t.Hour, t.Minute, t.Second, t.Nanosecond, time.Local)))
1875 return v, nil
1876 }
1877 if v.Kind() == reflect.Interface {
1878 return boxInto(v, reflect.ValueOf(t))
1879 }
1880 return reflect.Value{}, d.typeMismatchError("local time", v.Type(), d.p.Raw(value.Raw))
1881}
1882
1883func (d *decoder) assignArray(v reflect.Value, expr *unstable.Node, value *unstable.Node) (reflect.Value, error) {
1884 // Count the elements to allocate the target in one go.

Callers 1

assignValueMethod · 0.95

Calls 5

typeMismatchErrorMethod · 0.95
NewParserErrorFunction · 0.92
parseLocalTimeFunction · 0.85
boxIntoFunction · 0.85
RawMethod · 0.80

Tested by

no test coverage detected