diff --git a/draftlogs/7456_fix.md b/draftlogs/7456_fix.md new file mode 100644 index 00000000000..587a23d9995 --- /dev/null +++ b/draftlogs/7456_fix.md @@ -0,0 +1 @@ + - Fix Persian calendar leap year [[#7456](https://github.com/plotly/plotly.js/pull/7456)] diff --git a/package-lock.json b/package-lock.json index 4062c814583..312e3626c14 100644 --- a/package-lock.json +++ b/package-lock.json @@ -58,7 +58,7 @@ "to-px": "1.0.1", "topojson-client": "^3.1.0", "webgl-context": "^2.2.0", - "world-calendars": "^1.0.3" + "world-calendars": "^1.0.4" }, "devDependencies": { "@biomejs/biome": "1.8.3", @@ -10908,9 +10908,10 @@ } }, "node_modules/world-calendars": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/world-calendars/-/world-calendars-1.0.3.tgz", - "integrity": "sha1-slxQMrokEo/8QdCfr0pewbnBQzU=", + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/world-calendars/-/world-calendars-1.0.4.tgz", + "integrity": "sha512-VGRnLJS+xJmGDPodgJRnGIDwGu0s+Cr9V2HB3EzlDZ5n0qb8h5SJtGUEkjrphZYAglEiXZ6kiXdmk0H/h/uu/w==", + "license": "MIT", "dependencies": { "object-assign": "^4.1.0" } diff --git a/package.json b/package.json index 39f76f1a5dd..4ec25c55d5d 100644 --- a/package.json +++ b/package.json @@ -72,6 +72,7 @@ "@plotly/d3-sankey": "0.7.2", "@plotly/d3-sankey-circular": "0.33.1", "@plotly/mapbox-gl": "1.13.4", + "@plotly/regl": "^2.1.2", "@turf/area": "^7.1.0", "@turf/bbox": "^7.1.0", "@turf/centroid": "^7.1.0", @@ -105,7 +106,6 @@ "point-in-polygon": "^1.1.0", "polybooljs": "^1.2.2", "probe-image-size": "^7.2.3", - "@plotly/regl": "^2.1.2", "regl-error2d": "^2.0.12", "regl-line2d": "^3.1.3", "regl-scatter2d": "^3.3.1", @@ -117,10 +117,12 @@ "to-px": "1.0.1", "topojson-client": "^3.1.0", "webgl-context": "^2.2.0", - "world-calendars": "^1.0.3" + "world-calendars": "^1.0.4" }, "devDependencies": { "@biomejs/biome": "1.8.3", + "@plotly/mathjax-v2": "npm:mathjax@2.7.5", + "@plotly/mathjax-v3": "npm:mathjax@^3.2.2", "amdefine": "^1.0.1", "assert": "^2.1.0", "browserify-transform-tools": "^1.7.0", @@ -160,8 +162,6 @@ "karma-viewport": "1.0.2", "lodash": "^4.17.21", "madge": "^8.0.0", - "@plotly/mathjax-v2": "npm:mathjax@2.7.5", - "@plotly/mathjax-v3": "npm:mathjax@^3.2.2", "minify-stream": "^2.1.0", "npm-link-check": "^5.0.1", "open": "^8.4.2", diff --git a/test/jasmine/tests/lib_date_test.js b/test/jasmine/tests/lib_date_test.js index 55d6aa7b16c..186afd033a2 100644 --- a/test/jasmine/tests/lib_date_test.js +++ b/test/jasmine/tests/lib_date_test.js @@ -368,6 +368,64 @@ describe('dates', function() { expect(Lib.dateTime2ms(v, 'chinese')).toBeUndefined(v); }); }); + + it('Persian calendar should convert right values', function() { + var leapYears = [ + 479, 483, 487, 491, 495, 499, + 503, 508, 512, 516, 520, 524, 528, 532, 536, 541, 545, 549, 553, 557, 561, 565, 569, 574, 578, 582, 586, 590, 594, 598, + 602, 607, 611, 615, 619, 623, 627, 631, 636, 640, 644, 648, 652, 656, 660, 664, 669, 673, 677, 681, 685, 689, 693, 697, + 702, 706, 710, 714, 718, 722, 726, 730, 735, 739, 743, 747, 751, 755, 759, 764, 768, 772, 776, 780, 784, 788, 792, 797, + 801, 805, 809, 813, 817, 821, 825, 830, 834, 838, 842, 846, 850, 854, 858, 863, 867, 871, 875, 879, 883, 887, 892, 896, + 900, 904, 908, 912, 916, 920, 925, 929, 933, 937, 941, 945, 949, 953, 958, 962, 966, 970, 974, 978, 982, 986, 991, 995, 999, + 1003, 1007, 1011, 1015, 1020, 1024, 1028, 1032, 1036, 1040, 1044, 1048, 1053, 1057, 1061, 1065, 1069, 1073, 1077, 1081, 1086, 1090, 1094, 1098, + 1102, 1106, 1110, 1114, 1119, 1123, 1127, 1131, 1135, 1139, 1143, 1148, 1152, 1156, 1160, 1164, 1168, 1172, 1176, 1181, 1185, 1189, 1193, 1197, + 1201, 1205, 1209, 1214, 1218, 1222, 1226, 1230, 1234, 1238, 1242, 1247, 1251, 1255, 1259, 1263, 1267, 1271, 1276, 1280, 1284, 1288, 1292, 1296, + 1300, 1304, 1309, 1313, 1317, 1321, 1325, 1329, 1333, 1337, 1342, 1346, 1350, 1354, 1358, 1362, 1366, 1370, 1375, 1379, 1383, 1387, 1391, 1395, 1399, + 1403, 1408, 1412, 1416, 1420, 1424, 1428, 1432, 1437, 1441, 1445, 1449, 1453, 1457, 1461, 1465, 1470, 1474, 1478, 1482, 1486, 1490, 1494, 1498, + 1503, 1507, 1511, 1515, 1519, 1523 + ]; + + var dates = []; + + for(var y = 475; y < 1525; y++) { + if(y === 0) continue; + for(var m = 1; m <= 12; m++) { + for(var d = 1; d <= (m < 7 ? 31 : 30); d++) { + if(d === 30 && m === 12 && leapYears.indexOf(y) === -1) continue; + + dates.push([ + (y < 1000 ? '0' : '') + y, + (m < 10 ? '0' : '') + m, + (d < 10 ? '0' : '') + d + ].join('-')); + } + } + } + + var unixIndex = dates.indexOf('1348-10-11'); + + var tests = []; + for(var i = 0; i < dates.length; i++) { + var date = dates[i]; + var parts = date.split('-'); + var d = +parts[2]; + + // only test days at the start/end of months + if(d < 3 || d > 28) { + var time = (i - unixIndex) * 86400000; + + tests.push([date, time]); + } + } + + tests.forEach(function(v) { + var calendar = 'persian'; + var dateStr = v[0]; + var ms = v[1]; + expect(Lib.ms2DateTime(ms, 0, calendar)).toBe(dateStr); + expect(Lib.dateTime2ms(dateStr, calendar)).toBe(ms); + }); + }); }); describe('cleanDate', function() { pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy