19 lines
327 B
Go
19 lines
327 B
Go
package main
|
|
|
|
import (
|
|
"strconv"
|
|
"time"
|
|
)
|
|
|
|
// parseUnixTimestamp parses a string containing a UNIX timestamp to a time.Time.
|
|
func parseUnixTimestamp(timestamp string) (time.Time, error) {
|
|
var t = time.Time{}
|
|
|
|
i, err := strconv.ParseInt(timestamp, 10, 64)
|
|
if err != nil {
|
|
return t, err
|
|
}
|
|
|
|
return time.Unix(i, 0), nil
|
|
}
|