MCPcopy Create free account
hub / github.com/apache/fory / WriteData

Method WriteData

go/fory/time.go:138–153  ·  view source on GitHub ↗
(ctx *WriteContext, value reflect.Value)

Source from the content-addressed store, hash-verified

136}
137
138func (s dateSerializer) WriteData(ctx *WriteContext, value reflect.Value) {
139 date := value.Interface().(Date)
140 if ctx.TypeResolver().IsXlang() {
141 days, err := DateToEpochDay(date)
142 if err != nil {
143 ctx.SetError(FromError(err))
144 return
145 }
146 ctx.buffer.WriteVarint64(days)
147 return
148 }
149 diff := time.Date(date.Year, date.Month, date.Day, 0, 0, 0, 0, time.Local).Sub(
150 time.Date(1970, 1, 1, 0, 0, 0, 0, time.Local))
151 days := int64(diff.Hours() / 24)
152 ctx.buffer.WriteInt32(int32(days))
153}
154
155func (s dateSerializer) Read(ctx *ReadContext, refMode RefMode, readType bool, hasGenerics bool, value reflect.Value) {
156 err := ctx.Err()

Callers 1

WriteMethod · 0.95

Calls 11

DateToEpochDayFunction · 0.85
FromErrorFunction · 0.85
SubMethod · 0.80
int64Function · 0.50
int32Function · 0.50
IsXlangMethod · 0.45
TypeResolverMethod · 0.45
SetErrorMethod · 0.45
WriteVarint64Method · 0.45
DateMethod · 0.45
WriteInt32Method · 0.45

Tested by

no test coverage detected