UTC and Days operator question

Here’s some information regarding the current behaviour of the days:fieldname[n] operator, based on an examination of the code in $:/core/modules/filters/days.js:

  • By default, it uses the modified field of each input tiddler. Note that this field (or any other stored date field) is, by convention, always assumed to be stored as a UTC value.

  • It converts the field value to a date text string using $tw.utils.parseDate

  • This date text string is subsequently converted to a “timestamp” value with hours set to (0,0,0,0)

  • To find qualifying titles, it calculates a “targetTimeStamp” Date() object with hours set to (0,0,0,0), using the dayInterval filter operand to calculate days as milliseconds (1000*60*60*24*dayInterval)

  • It then subtracts the tiddler timestamp with hours=(0,0,0,0) from the targetTimeStamp to determine if the tiddler timestamp isWithinDays by examining the if the sign of the resulting value is positive, 0, or negative.

  • Note that none of these internally computed values are adjusted for a local timezone offset.

Thus, all comparisons used by the days[] operator are assuming that the tiddler date field values are stored as UTC times.

-e