Skip to content

Commit

Permalink
Merge pull request #421 from spencermountain/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
spencermountain authored Dec 1, 2024
2 parents 656edbb + ad567c5 commit 5566447
Show file tree
Hide file tree
Showing 13 changed files with 255 additions and 261 deletions.
75 changes: 37 additions & 38 deletions builds/spacetime.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* spencermountain/spacetime 7.6.2 Apache 2.0 */
/* spencermountain/spacetime 7.7.0 Apache 2.0 */
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
Expand Down Expand Up @@ -58,11 +58,11 @@
var data = {
"9|s": "2/dili,2/jayapura",
"9|n": "2/chita,2/khandyga,2/pyongyang,2/seoul,2/tokyo,2/yakutsk,11/palau,japan,rok",
"9.5|s|04/07:03->10/06:04": "4/adelaide,4/broken_hill,4/south,4/yancowinna",
"9.5|s|04/06:03->10/05:04": "4/adelaide,4/broken_hill,4/south,4/yancowinna",
"9.5|s": "4/darwin,4/north",
"8|s|03/13:01->10/02:00": "12/casey",
"8|s": "2/kuala_lumpur,2/makassar,2/singapore,4/perth,2/ujung_pandang,4/west,singapore",
"8|n": "2/brunei,2/choibalsan,2/hong_kong,2/irkutsk,2/kuching,2/macau,2/manila,2/shanghai,2/taipei,2/ulaanbaatar,2/chongqing,2/chungking,2/harbin,2/macao,2/ulan_bator,hongkong,prc,roc",
"8|n": "2/brunei,2/hong_kong,2/irkutsk,2/kuching,2/macau,2/manila,2/shanghai,2/taipei,2/ulaanbaatar,2/chongqing,2/chungking,2/harbin,2/macao,2/ulan_bator,2/choibalsan,hongkong,prc,roc",
"8.75|s": "4/eucla",
"7|s": "12/davis,2/jakarta,9/christmas",
"7|n": "2/bangkok,2/barnaul,2/hovd,2/krasnoyarsk,2/novokuznetsk,2/novosibirsk,2/phnom_penh,2/pontianak,2/ho_chi_minh,2/tomsk,2/vientiane,2/saigon",
Expand All @@ -77,67 +77,67 @@
"4|n": "2/baku,2/dubai,2/muscat,2/tbilisi,2/yerevan,8/astrakhan,8/samara,8/saratov,8/ulyanovsk,8/volgograd,9/mahe,9/mauritius,2/volgograd",
"4.5|n": "2/kabul",
"3|s": "12/syowa,9/antananarivo",
"3|n|04/26:02->10/31:24": "0/cairo,egypt",
"3|n|04/20:04->10/26:02": "2/gaza,2/hebron",
"3|n|03/31:05->10/27:04": "2/famagusta,2/nicosia,8/athens,8/bucharest,8/helsinki,8/kyiv,8/mariehamn,8/riga,8/sofia,8/tallinn,8/uzhgorod,8/vilnius,8/zaporozhye,8/nicosia,8/kiev,eet",
"3|n|03/31:04->10/27:03": "8/chisinau,8/tiraspol",
"3|n|03/31:02->10/26:24": "2/beirut",
"3|n|03/29:04->10/27:02": "2/jerusalem,2/tel_aviv,israel",
"3|n|04/25:02->10/30:24": "0/cairo,egypt",
"3|n|04/12:04->10/25:02": "2/gaza,2/hebron",
"3|n|03/30:05->10/26:04": "2/famagusta,2/nicosia,8/athens,8/bucharest,8/helsinki,8/kyiv,8/mariehamn,8/riga,8/sofia,8/tallinn,8/uzhgorod,8/vilnius,8/zaporozhye,8/nicosia,8/kiev,eet",
"3|n|03/30:04->10/26:03": "8/chisinau,8/tiraspol",
"3|n|03/30:02->10/25:24": "2/beirut",
"3|n|03/28:04->10/26:02": "2/jerusalem,2/tel_aviv,israel",
"3|n": "0/addis_ababa,0/asmara,0/asmera,0/dar_es_salaam,0/djibouti,0/juba,0/kampala,0/mogadishu,0/nairobi,2/aden,2/amman,2/baghdad,2/bahrain,2/damascus,2/kuwait,2/qatar,2/riyadh,8/istanbul,8/kirov,8/minsk,8/moscow,8/simferopol,9/comoro,9/mayotte,2/istanbul,turkey,w-su",
"3.5|n": "2/tehran,iran",
"2|s|03/31:04->10/27:02": "12/troll",
"2|s|03/30:04->10/26:02": "12/troll",
"2|s": "0/gaborone,0/harare,0/johannesburg,0/lubumbashi,0/lusaka,0/maputo,0/maseru,0/mbabane",
"2|n|03/31:04->10/27:03": "0/ceuta,arctic/longyearbyen,8/amsterdam,8/andorra,8/belgrade,8/berlin,8/bratislava,8/brussels,8/budapest,8/busingen,8/copenhagen,8/gibraltar,8/ljubljana,8/luxembourg,8/madrid,8/malta,8/monaco,8/oslo,8/paris,8/podgorica,8/prague,8/rome,8/san_marino,8/sarajevo,8/skopje,8/stockholm,8/tirane,8/vaduz,8/vatican,8/vienna,8/warsaw,8/zagreb,8/zurich,3/jan_mayen,poland,cet,met",
"2|n|03/30:04->10/26:03": "0/ceuta,arctic/longyearbyen,8/amsterdam,8/andorra,8/belgrade,8/berlin,8/bratislava,8/brussels,8/budapest,8/busingen,8/copenhagen,8/gibraltar,8/ljubljana,8/luxembourg,8/madrid,8/malta,8/monaco,8/oslo,8/paris,8/podgorica,8/prague,8/rome,8/san_marino,8/sarajevo,8/skopje,8/stockholm,8/tirane,8/vaduz,8/vatican,8/vienna,8/warsaw,8/zagreb,8/zurich,3/jan_mayen,poland,cet,met",
"2|n": "0/blantyre,0/bujumbura,0/khartoum,0/kigali,0/tripoli,8/kaliningrad,libya",
"1|s": "0/brazzaville,0/kinshasa,0/luanda,0/windhoek",
"1|n|03/31:03->10/27:02": "3/canary,3/faroe,3/madeira,8/dublin,8/guernsey,8/isle_of_man,8/jersey,8/lisbon,8/london,3/faeroe,eire,8/belfast,gb-eire,gb,portugal,wet",
"1|n|03/30:03->10/26:02": "3/canary,3/faroe,3/madeira,8/dublin,8/guernsey,8/isle_of_man,8/jersey,8/lisbon,8/london,3/faeroe,eire,8/belfast,gb-eire,gb,portugal,wet",
"1|n": "0/algiers,0/bangui,0/douala,0/lagos,0/libreville,0/malabo,0/ndjamena,0/niamey,0/porto-novo,0/tunis",
"14|n": "11/kiritimati",
"13|s": "11/apia,11/tongatapu",
"13|n": "11/enderbury,11/kanton,11/fakaofo",
"12|s|04/07:03->09/29:04": "12/mcmurdo,11/auckland,12/south_pole,nz",
"12|s|04/06:03->09/28:04": "12/mcmurdo,11/auckland,12/south_pole,nz",
"12|s": "11/fiji",
"12|n": "2/anadyr,2/kamchatka,2/srednekolymsk,11/funafuti,11/kwajalein,11/majuro,11/nauru,11/tarawa,11/wake,11/wallis,kwajalein",
"12.75|s|04/07:03->04/07:02": "11/chatham,nz-chat",
"11|s|04/07:03->10/06:04": "12/macquarie",
"12.75|s|04/06:03->04/06:02": "11/chatham,nz-chat",
"11|s|04/06:03->10/05:04": "12/macquarie",
"11|s": "11/bougainville",
"11|n": "2/magadan,2/sakhalin,11/efate,11/guadalcanal,11/kosrae,11/noumea,11/pohnpei,11/ponape",
"11.5|n|04/07:03->10/06:04": "11/norfolk",
"10|s|04/07:03->10/06:04": "4/currie,4/hobart,4/melbourne,4/sydney,4/act,4/canberra,4/nsw,4/tasmania,4/victoria",
"11.5|n|04/06:03->10/05:04": "11/norfolk",
"10|s|04/06:03->10/05:04": "4/currie,4/hobart,4/melbourne,4/sydney,4/act,4/canberra,4/nsw,4/tasmania,4/victoria",
"10|s": "12/dumontdurville,4/brisbane,4/lindeman,11/port_moresby,4/queensland",
"10|n": "2/ust-nera,2/vladivostok,11/guam,11/saipan,11/chuuk,11/truk,11/yap",
"10.5|s|04/07:01->10/06:02": "4/lord_howe,4/lhi",
"0|s|03/10:03->04/14:04": "0/casablanca,0/el_aaiun",
"0|n|03/31:02->10/27:01": "3/azores",
"0|n|03/31:01->10/26:24": "1/scoresbysund",
"10.5|s|04/06:01->10/05:02": "4/lord_howe,4/lhi",
"0|s|02/23:03->04/06:04": "0/casablanca,0/el_aaiun",
"0|n|03/30:02->10/26:01": "3/azores",
"0|n|03/30:01->10/25:24": "1/scoresbysund",
"0|n": "0/abidjan,0/accra,0/bamako,0/banjul,0/bissau,0/conakry,0/dakar,0/freetown,0/lome,0/monrovia,0/nouakchott,0/ouagadougou,0/sao_tome,1/danmarkshavn,3/reykjavik,3/st_helena,13/gmt,13/utc,0/timbuktu,13/greenwich,13/uct,13/universal,13/zulu,gmt-0,gmt+0,gmt0,greenwich,iceland,uct,universal,utc,zulu,13/unknown,factory",
"-9|n|03/10:04->11/03:02": "1/adak,1/atka,us/aleutian",
"-9|n|03/09:04->11/02:02": "1/adak,1/atka,us/aleutian",
"-9|n": "11/gambier",
"-9.5|n": "11/marquesas",
"-8|n|03/10:04->11/03:02": "1/anchorage,1/juneau,1/metlakatla,1/nome,1/sitka,1/yakutat,us/alaska",
"-8|n|03/09:04->11/02:02": "1/anchorage,1/juneau,1/metlakatla,1/nome,1/sitka,1/yakutat,us/alaska",
"-8|n": "11/pitcairn",
"-7|n|03/10:04->11/03:02": "1/los_angeles,1/santa_isabel,1/tijuana,1/vancouver,1/ensenada,6/pacific,10/bajanorte,us/pacific-new,us/pacific",
"-7|n|03/09:04->11/02:02": "1/los_angeles,1/santa_isabel,1/tijuana,1/vancouver,1/ensenada,6/pacific,10/bajanorte,us/pacific-new,us/pacific",
"-7|n": "1/creston,1/dawson,1/dawson_creek,1/fort_nelson,1/hermosillo,1/mazatlan,1/phoenix,1/whitehorse,6/yukon,10/bajasur,us/arizona,mst",
"-6|s|04/06:22->09/07:24": "11/easter,7/easterisland",
"-6|s|04/05:22->09/06:24": "11/easter,7/easterisland",
"-6|n|04/07:02->10/27:02": "1/merida",
"-6|n|03/10:04->11/03:02": "1/boise,1/cambridge_bay,1/denver,1/edmonton,1/inuvik,1/north_dakota,1/ojinaga,1/ciudad_juarez,1/yellowknife,1/shiprock,6/mountain,navajo,us/mountain",
"-6|n|03/09:04->11/02:02": "1/boise,1/cambridge_bay,1/denver,1/edmonton,1/inuvik,1/north_dakota,1/ojinaga,1/ciudad_juarez,1/yellowknife,1/shiprock,6/mountain,navajo,us/mountain",
"-6|n": "1/bahia_banderas,1/belize,1/chihuahua,1/costa_rica,1/el_salvador,1/guatemala,1/managua,1/mexico_city,1/monterrey,1/regina,1/swift_current,1/tegucigalpa,11/galapagos,6/east-saskatchewan,6/saskatchewan,10/general",
"-5|s": "1/lima,1/rio_branco,1/porto_acre,5/acre",
"-5|n|03/10:04->11/03:02": "1/chicago,1/matamoros,1/menominee,1/rainy_river,1/rankin_inlet,1/resolute,1/winnipeg,1/indiana/knox,1/indiana/tell_city,1/north_dakota/beulah,1/north_dakota/center,1/north_dakota/new_salem,1/knox_in,6/central,us/central,us/indiana-starke",
"-5|n|03/09:04->11/02:02": "1/chicago,1/matamoros,1/menominee,1/rainy_river,1/rankin_inlet,1/resolute,1/winnipeg,1/indiana/knox,1/indiana/tell_city,1/north_dakota/beulah,1/north_dakota/center,1/north_dakota/new_salem,1/knox_in,6/central,us/central,us/indiana-starke",
"-5|n": "1/bogota,1/cancun,1/cayman,1/coral_harbour,1/eirunepe,1/guayaquil,1/jamaica,1/panama,1/atikokan,jamaica,est",
"-4|s|04/06:24->09/08:02": "1/santiago,7/continental",
"-4|s|03/23:24->10/06:02": "1/asuncion",
"-4|s|04/05:24->09/07:02": "1/santiago,7/continental",
"-4|s|03/22:24->10/05:02": "1/asuncion",
"-4|s": "1/campo_grande,1/cuiaba,1/la_paz,1/manaus,5/west",
"-4|n|03/10:04->11/03:02": "1/detroit,1/grand_turk,1/indiana,1/indianapolis,1/iqaluit,1/kentucky,1/louisville,1/montreal,1/nassau,1/new_york,1/nipigon,1/pangnirtung,1/port-au-prince,1/thunder_bay,1/toronto,1/indiana/marengo,1/indiana/petersburg,1/indiana/vevay,1/indiana/vincennes,1/indiana/winamac,1/kentucky/monticello,1/fort_wayne,1/indiana/indianapolis,1/kentucky/louisville,6/eastern,us/east-indiana,us/eastern,us/michigan",
"-4|n|03/10:02->11/03:01": "1/havana,cuba",
"-4|n|03/09:04->11/02:02": "1/detroit,1/grand_turk,1/indiana,1/indianapolis,1/iqaluit,1/kentucky,1/louisville,1/montreal,1/nassau,1/new_york,1/nipigon,1/pangnirtung,1/port-au-prince,1/thunder_bay,1/toronto,1/indiana/marengo,1/indiana/petersburg,1/indiana/vevay,1/indiana/vincennes,1/indiana/winamac,1/kentucky/monticello,1/fort_wayne,1/indiana/indianapolis,1/kentucky/louisville,6/eastern,us/east-indiana,us/eastern,us/michigan",
"-4|n|03/09:02->11/02:01": "1/havana,cuba",
"-4|n": "1/anguilla,1/antigua,1/aruba,1/barbados,1/blanc-sablon,1/boa_vista,1/caracas,1/curacao,1/dominica,1/grenada,1/guadeloupe,1/guyana,1/kralendijk,1/lower_princes,1/marigot,1/martinique,1/montserrat,1/port_of_spain,1/porto_velho,1/puerto_rico,1/santo_domingo,1/st_barthelemy,1/st_kitts,1/st_lucia,1/st_thomas,1/st_vincent,1/tortola,1/virgin",
"-3|s": "1/argentina,1/buenos_aires,1/catamarca,1/cordoba,1/fortaleza,1/jujuy,1/mendoza,1/montevideo,1/punta_arenas,1/sao_paulo,12/palmer,12/rothera,3/stanley,1/argentina/la_rioja,1/argentina/rio_gallegos,1/argentina/salta,1/argentina/san_juan,1/argentina/san_luis,1/argentina/tucuman,1/argentina/ushuaia,1/argentina/comodrivadavia,1/argentina/buenos_aires,1/argentina/catamarca,1/argentina/cordoba,1/argentina/jujuy,1/argentina/mendoza,1/argentina/rosario,1/rosario,5/east",
"-3|n|03/10:04->11/03:02": "1/glace_bay,1/goose_bay,1/halifax,1/moncton,1/thule,3/bermuda,6/atlantic",
"-3|n|03/09:04->11/02:02": "1/glace_bay,1/goose_bay,1/halifax,1/moncton,1/thule,3/bermuda,6/atlantic",
"-3|n": "1/araguaina,1/bahia,1/belem,1/cayenne,1/maceio,1/paramaribo,1/recife,1/santarem",
"-2|n|03/31:01->10/26:24": "1/nuuk,1/godthab",
"-2|n|03/10:04->11/03:02": "1/miquelon",
"-2|n|03/09:04->11/02:02": "1/miquelon",
"-2|n": "1/noronha,3/south_georgia,5/denoronha",
"-2.5|n|03/10:04->11/03:02": "1/st_johns,6/newfoundland",
"-2.5|n|03/09:04->11/02:02": "1/st_johns,6/newfoundland",
"-1|n|03/30:01->10/25:24": "1/nuuk,1/godthab",
"-1|n": "3/cape_verde",
"-11|n": "11/midway,11/niue,11/pago_pago,11/samoa,us/samoa",
"-10|n": "11/honolulu,11/johnston,11/rarotonga,11/tahiti,us/hawaii,hst"
Expand Down Expand Up @@ -3356,7 +3356,7 @@
if (tmp.date() === 1) {
toAdd = 0;
}
tmp = tmp.minus(1, 'second');
tmp = tmp.minus(2, 'hours');
const thisOne = this.epoch;
//if the week technically hasn't started yet
if (tmp.epoch > thisOne) {
Expand All @@ -3365,7 +3365,6 @@
//speed it up, if we can
let i = 0;
let skipWeeks = this.month() * 4;
// console.log(ms.week+ " "+ skipWeeks);
tmp.epoch += ms.week * skipWeeks;
i += skipWeeks;
for (; i <= 52; i++) {
Expand Down Expand Up @@ -4136,7 +4135,7 @@
};
var whereIts$1 = whereIts;

var version = '7.6.2';
var version = '7.7.0';

const main = (input, tz, options) => new Spacetime(input, tz, options);

Expand Down
2 changes: 1 addition & 1 deletion builds/spacetime.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion builds/spacetime.mjs

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ This project follows semVer, where:
-->

### 7.7.0 [Dec 2024]
- **[fix]** - .week() issue \#303
- **[update]** - 2025 DST changes
- **[update]** - greenland Nuuk DST change \#420
- **[update]** - alias choibalsan to ulaanbaatar


### 7.6.2 [Oct 2024]
- **[fix]** - isEqual null on 1970-01-01 #417

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "spacetime",
"version": "7.6.2",
"version": "7.7.0",
"description": "figure-out dates across timezones",
"main": "src/index.js",
"unpkg": "builds/spacetime.min.js",
Expand Down
33 changes: 3 additions & 30 deletions scratch.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,8 @@
// const spacetime = require('./builds/spacetime.cjs')
import spacetime from './src/index.js'

// console.log(spacetime('Feb 29 2001').iso())
// console.log(spacetime('2001-02-02T12Z').tz)
// console.log(spacetime('', 'Africa/Cairo').timezone())

console.log(spacetime('1970-01-01', 'gmt').isEqual('1970-01-01'))
// console.log(spacetime('1970-01-02', 'gmt').isEqual('1970-01-02'))
// console.log(spacetime('1970-01-02', 'gmt').isEqual('1970-01-01'))
// console.log(spacetime('1970-01-01', 'gmt').isEqual('1970-01-02'))

// let s = spacetime(null, 'pacific/fiji')
// console.log(s.time())
// console.log(s.timezone())
// s = s.minus(5, 'months')
// console.log(s.time())
// console.log(s.timezone())

// s = spacetime(null, 'America/Toronto')
// console.log(s.time())
// console.log(s.timezone())

/*
bahia_banderas
chihuahua
mazatlan
merida
mexico_city
monterrey
amman
damascus
tehran
fiji
*/
const date = spacetime.now().week(14);
console.log(date.iso())
console.log(date.week())
2 changes: 1 addition & 1 deletion scripts/updateZonefile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import sh from 'shelljs'
sh.config.silent = true
import data from '../zonefile/iana.js'
import { writeFileSync } from 'fs'
const year = 2024 //new Date().getFullYear()
const year = 2025 //new Date().getFullYear()
// /usr/share/zoneinfo only stores changes, and will use the most-recent change
// see /usr/share/zoneinfo/Africa/Algiers - has changes scheduled for 2038

Expand Down
2 changes: 1 addition & 1 deletion src/_version.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export default '7.6.2'
export default '7.7.0'
3 changes: 1 addition & 2 deletions src/methods/query/03-year.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const methods = {
if (tmp.date() === 1) {
toAdd = 0
}
tmp = tmp.minus(1, 'second')
tmp = tmp.minus(2, 'hours')
const thisOne = this.epoch
//if the week technically hasn't started yet
if (tmp.epoch > thisOne) {
Expand All @@ -72,7 +72,6 @@ const methods = {
//speed it up, if we can
let i = 0
let skipWeeks = this.month() * 4
// console.log(ms.week+ " "+ skipWeeks);
tmp.epoch += ms.week * skipWeeks
i += skipWeeks
for (; i <= 52; i++) {
Expand Down
19 changes: 19 additions & 0 deletions test/week.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,23 @@ test('jan 1 is always first week', (t) => {
t.equal(s.week(), 1, year + ' week')
}
t.end()
})

test('week input=output', (t) => {
for (let w = 1; w < 52; w += 1) {
const date = spacetime.now().week(w);
t.equal(date.week(), w, `week ${w}`)
}

let tz = 'africa/addis_ababa'
for (let w = 1; w < 52; w += 1) {
const date = spacetime.now(tz).week(w);
t.equal(date.week(), w, `${tz} week ${w}`)
}
tz = 'america/chicago'
for (let w = 1; w < 52; w += 1) {
const date = spacetime.now(tz).week(w);
t.equal(date.week(), w, `${tz} week ${w}`)
}
t.end()
})
Loading

0 comments on commit 5566447

Please sign in to comment.