mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-16 12:50:38 -07:00
fix(date): %s returns Unix epoch unaffected by display timezone (#932)
The %s handler read LiquidDate.getTime(), which returns the displayDate deliberately shifted by the display timezone offset for wall-clock getters. With a timezone argument or timezoneOffset option set, %s produced an epoch shifted by (server offset - display offset) instead of the true Unix timestamp. Expose the unshifted time as LiquidDate.dateValue() and use it for %s. Also switch Math.round to Math.floor so fractional seconds truncate toward the epoch like Ruby strftime. Fixes #931
This commit is contained in:
@@ -34,6 +34,7 @@ The `date` filter is used to convert a timestamp into the specified format.
|
||||
* minutes: `-360` means `'+06:00'` and `360` means `'-06:00'`
|
||||
* timeZone ID: `Asia/Colombo` or `America/New_York`
|
||||
* See [here](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) for TZ database values
|
||||
* `%s` (seconds since the Unix epoch) identifies an instant rather than a wall-clock time, so it's not affected by the display timezone.
|
||||
|
||||
### Examples
|
||||
```liquid
|
||||
|
||||
Reference in New Issue
Block a user