Skip to content

Instantly share code, notes, and snippets.

View alirussell's full-sized avatar

Alistair Russell alirussell

View GitHub Profile
@alirussell
alirussell / is_british_summertime.js
Last active April 15, 2024 09:25
Check for british summer time (BST) in JavaScript
function lastSunday(month, year) {
var d = new Date();
var lastDayOfMonth = new Date(Date.UTC(year || d.getFullYear(), month+1, 0));
var day = lastDayOfMonth.getDay();
return new Date(Date.UTC(lastDayOfMonth.getFullYear(), lastDayOfMonth.getMonth(), lastDayOfMonth.getDate() - day));
}
function isBST(date) {
var d = date || new Date();
var starts = lastSunday(2, d.getFullYear());

Keybase proof

I hereby claim:

  • I am alirussell on github.
  • I am alirussell (https://keybase.io/alirussell) on keybase.
  • I have a public key whose fingerprint is D36F 58C3 2FE4 5152 577A 5771 70C6 8A1D E480 8A85

To claim this, I am signing this object: