Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 021289c

Browse files
authored
Merge pull request #7456 from plotly/persian-leap-year
Fix Persian calendar leap year
2 parents 5e2163b + 83ba2c5 commit 021289c

File tree

4 files changed

+68
-8
lines changed

4 files changed

+68
-8
lines changed

‎draftlogs/7456_fix.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Fix Persian calendar leap year [[#7456](https://github.com/plotly/plotly.js/pull/7456)]

‎package-lock.json

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
"@plotly/d3-sankey": "0.7.2",
7373
"@plotly/d3-sankey-circular": "0.33.1",
7474
"@plotly/mapbox-gl": "1.13.4",
75+
"@plotly/regl": "^2.1.2",
7576
"@turf/area": "^7.1.0",
7677
"@turf/bbox": "^7.1.0",
7778
"@turf/centroid": "^7.1.0",
@@ -105,7 +106,6 @@
105106
"point-in-polygon": "^1.1.0",
106107
"polybooljs": "^1.2.2",
107108
"probe-image-size": "^7.2.3",
108-
"@plotly/regl": "^2.1.2",
109109
"regl-error2d": "^2.0.12",
110110
"regl-line2d": "^3.1.3",
111111
"regl-scatter2d": "^3.3.1",
@@ -117,10 +117,12 @@
117117
"to-px": "1.0.1",
118118
"topojson-client": "^3.1.0",
119119
"webgl-context": "^2.2.0",
120-
"world-calendars": "^1.0.3"
120+
"world-calendars": "^1.0.4"
121121
},
122122
"devDependencies": {
123123
"@biomejs/biome": "1.8.3",
124+
"@plotly/mathjax-v2": "npm:mathjax@2.7.5",
125+
"@plotly/mathjax-v3": "npm:mathjax@^3.2.2",
124126
"amdefine": "^1.0.1",
125127
"assert": "^2.1.0",
126128
"browserify-transform-tools": "^1.7.0",
@@ -160,8 +162,6 @@
160162
"karma-viewport": "1.0.2",
161163
"lodash": "^4.17.21",
162164
"madge": "^8.0.0",
163-
"@plotly/mathjax-v2": "npm:mathjax@2.7.5",
164-
"@plotly/mathjax-v3": "npm:mathjax@^3.2.2",
165165
"minify-stream": "^2.1.0",
166166
"npm-link-check": "^5.0.1",
167167
"open": "^8.4.2",

‎test/jasmine/tests/lib_date_test.js

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,64 @@ describe('dates', function() {
368368
expect(Lib.dateTime2ms(v, 'chinese')).toBeUndefined(v);
369369
});
370370
});
371+
372+
it('Persian calendar should convert right values', function() {
373+
var leapYears = [
374+
479, 483, 487, 491, 495, 499,
375+
503, 508, 512, 516, 520, 524, 528, 532, 536, 541, 545, 549, 553, 557, 561, 565, 569, 574, 578, 582, 586, 590, 594, 598,
376+
602, 607, 611, 615, 619, 623, 627, 631, 636, 640, 644, 648, 652, 656, 660, 664, 669, 673, 677, 681, 685, 689, 693, 697,
377+
702, 706, 710, 714, 718, 722, 726, 730, 735, 739, 743, 747, 751, 755, 759, 764, 768, 772, 776, 780, 784, 788, 792, 797,
378+
801, 805, 809, 813, 817, 821, 825, 830, 834, 838, 842, 846, 850, 854, 858, 863, 867, 871, 875, 879, 883, 887, 892, 896,
379+
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,
380+
1003, 1007, 1011, 1015, 1020, 1024, 1028, 1032, 1036, 1040, 1044, 1048, 1053, 1057, 1061, 1065, 1069, 1073, 1077, 1081, 1086, 1090, 1094, 1098,
381+
1102, 1106, 1110, 1114, 1119, 1123, 1127, 1131, 1135, 1139, 1143, 1148, 1152, 1156, 1160, 1164, 1168, 1172, 1176, 1181, 1185, 1189, 1193, 1197,
382+
1201, 1205, 1209, 1214, 1218, 1222, 1226, 1230, 1234, 1238, 1242, 1247, 1251, 1255, 1259, 1263, 1267, 1271, 1276, 1280, 1284, 1288, 1292, 1296,
383+
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,
384+
1403, 1408, 1412, 1416, 1420, 1424, 1428, 1432, 1437, 1441, 1445, 1449, 1453, 1457, 1461, 1465, 1470, 1474, 1478, 1482, 1486, 1490, 1494, 1498,
385+
1503, 1507, 1511, 1515, 1519, 1523
386+
];
387+
388+
var dates = [];
389+
390+
for(var y = 475; y < 1525; y++) {
391+
if(y === 0) continue;
392+
for(var m = 1; m <= 12; m++) {
393+
for(var d = 1; d <= (m < 7 ? 31 : 30); d++) {
394+
if(d === 30 && m === 12 && leapYears.indexOf(y) === -1) continue;
395+
396+
dates.push([
397+
(y < 1000 ? '0' : '') + y,
398+
(m < 10 ? '0' : '') + m,
399+
(d < 10 ? '0' : '') + d
400+
].join('-'));
401+
}
402+
}
403+
}
404+
405+
var unixIndex = dates.indexOf('1348年10月11日');
406+
407+
var tests = [];
408+
for(var i = 0; i < dates.length; i++) {
409+
var date = dates[i];
410+
var parts = date.split('-');
411+
var d = +parts[2];
412+
413+
// only test days at the start/end of months
414+
if(d < 3 || d > 28) {
415+
var time = (i - unixIndex) * 86400000;
416+
417+
tests.push([date, time]);
418+
}
419+
}
420+
421+
tests.forEach(function(v) {
422+
var calendar = 'persian';
423+
var dateStr = v[0];
424+
var ms = v[1];
425+
expect(Lib.ms2DateTime(ms, 0, calendar)).toBe(dateStr);
426+
expect(Lib.dateTime2ms(dateStr, calendar)).toBe(ms);
427+
});
428+
});
371429
});
372430

373431
describe('cleanDate', function() {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /