cast icon indicating copy to clipboard operation
cast copied to clipboard

[BUG] Unixtimestemp in string

Open weldpua2008 opened this issue 4 years ago • 0 comments

panic: 2> unable to parse date: 1600285405

Code for reproduction:

https://play.golang.org/p/yyxxFcFhQg1

package main

import (
	"fmt"
	cast "github.com/spf13/cast"
)

func main() {
	val, err := cast.ToTimeE(1600285405)
	if err != nil {
		panic(fmt.Sprintf("1> %v", err))
	}
	fmt.Println(val)

	val, err = cast.ToTimeE(fmt.Sprintf("%v", 1600285405))
	fmt.Println(val)

	if err != nil {
		panic(fmt.Sprintf("2> %v", err))
	}
}

weldpua2008 avatar Sep 16 '20 19:09 weldpua2008