google / starlark-go

Starlark in Go: the Starlark configuration language, implemented in Go
BSD 3-Clause "New" or "Revised" License
2.26k stars 204 forks source link

lib/time: consider any Time other than zero instant to be truthy #441

Closed SamWheating closed 1 year ago

SamWheating commented 1 year ago

I know that the truthiness of timestamps isn't well defined, but the current behaviour is the opposite of what I would expect:

Welcome to Starlark (go.starlark.net)
>>> bool(time.now())
False
>>> bool(time.parse_time("0001-01-01T00:00:00Z"))
True

This change inverts the existing logic so that any time other than 0001-01-01T00:00:00Z will evaluate to True.

Alternatively, I think that considering all times to be True would also be acceptable. Thoughts?