ebx-timezone-mock
A JavaScript library which mocks the Date
object and lets you specify a local date/time/timezone in order to enable consistent testing of date/time-related code independently of your local system time settings.
It works by monkey patching the Date
object and returning results which are adjusted to reflect the effects of both the specified current date/time/timezone (if any) and the current date/time/timezone. In particular, it avoids problems caused by certain JavaScript date/time methods e.g. getHours
returning results in the user's local system time, so you can write date/time-related unit tests which will work whenever and wherever they are run, without changing timezones causing results to change.