(ctx *WriteContext, value reflect.Value)
| 136 | } |
| 137 | |
| 138 | func (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 | |
| 155 | func (s dateSerializer) Read(ctx *ReadContext, refMode RefMode, readType bool, hasGenerics bool, value reflect.Value) { |
| 156 | err := ctx.Err() |
no test coverage detected