MCPcopy Create free account
hub / github.com/chanify/chanify / parseTimestamp

Function parseTimestamp

core/msgparam.go:306–329  ·  view source on GitHub ↗
(t interface{})

Source from the content-addressed store, hash-verified

304}
305
306func parseTimestamp(t interface{}) *time.Time {
307 switch val := t.(type) {
308 case int:
309 v := time.Unix(int64(val)/1000, int64(val)%1000*1e6)
310 return &v
311 case uint:
312 v := time.Unix(int64(val)/1000, int64(val)%1000*1e6)
313 return &v
314 case int64:
315 v := time.Unix(val/1000, val%1000*1e6)
316 return &v
317 case uint64:
318 v := time.Unix(int64(val)/1000, int64(val)%1000*1e6)
319 return &v
320 case string:
321 if v, err := time.Parse(time.RFC3339Nano, val); err == nil {
322 return &v
323 } else if v, err := strconv.ParseUint(val, 10, 64); err == nil {
324 vv := time.Unix(int64(v)/1000, int64(v)%1000*1e6)
325 return &vv
326 }
327 }
328 return nil
329}
330
331func readFileFromForm(form *multipart.Form, name string) ([]byte, string, error) {
332 fs := form.File[name]

Callers 4

ParseJSONMethod · 0.85
ParseFormMethod · 0.85
tryFormTimestampFunction · 0.85
TestParseTimestampFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestParseTimestampFunction · 0.68