Before this commit epoch-like functions required time.Time type on input. It worked well for atomic Snowplow fields like collector_tstamp.
It becomes problematic when some nested context fields representing time are passed. Such fields don't use time.Time, they are plain strings.
This commit makes epoch/epochMillis functions more flexible:
When input is time.Time - just use it as is (atomic fields).
When input is a string - try to parse it as time.Time.
When input is something different - return an error.
In case of a string there are various time layouts that could be used for parsing. That's why epoch/epochMillis also accept (optional!) additional string parameter representing time layout. Layout must be valid go layout. Default value is 2006-01-02T15:04:05.999Z.
ref: PDP-1539
Before this commit
epoch
-like functions requiredtime.Time
type on input. It worked well for atomic Snowplow fields likecollector_tstamp
.It becomes problematic when some nested context fields representing time are passed. Such fields don't use
time.Time
, they are plain strings.This commit makes
epoch
/epochMillis
functions more flexible:time.Time
- just use it as is (atomic fields).time.Time
.In case of a string there are various time layouts that could be used for parsing. That's why
epoch
/epochMillis
also accept (optional!) additional string parameter representing time layout. Layout must be valid go layout. Default value is2006-01-02T15:04:05.999Z
.