Skip to content

Commit

Permalink
regenerate hebrew hijra calendar
Browse files Browse the repository at this point in the history
  • Loading branch information
commenthol committed Dec 22, 2018
1 parent 109cbb8 commit 0443a0f
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 19 deletions.
1 change: 1 addition & 0 deletions gen/hebrew-calender/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
22 changes: 13 additions & 9 deletions gen/hebrew-calender/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,26 @@
* ```
*/

var Hebcal = require('hebcal')
const fs = require('fs')
const Hebcal = require('hebcal')

var out = {}
const filename = `${__dirname}/../../src/internal/hebrew-calendar.js`
const out = {}

for (let y = 1969; y <= 2100; y++) {
var yd = 5730 - 1970 // difference between jewish and gregorian years
var iy = yd + y
const yd = 5730 - 1970 // difference between jewish and gregorian years
const iy = yd + y

if (!out.year) {
out.year = iy
}
var iyy = iy - out.year
const iyy = iy - out.year

for (let im = 1; im <= 12; im++) {
var m = new Hebcal.HDate(1, im, iy).greg()
const m = new Hebcal.HDate(1, im, iy).greg()

var my = m.getFullYear()
var mm = im - 1
const my = m.getFullYear()
const mm = im - 1

if (!out[my]) {
out[my] = []
Expand All @@ -41,6 +43,8 @@ for (let y = 1969; y <= 2100; y++) {
}
}
}
console.log('/*eslint-disable*/\nmodule.exports=' + JSON.stringify(out).replace(/"/g, '')) // eslint-disable-line

const final = '/*eslint-disable*/\nmodule.exports=' + JSON.stringify(out).replace(/"/g, '')
fs.writeFileSync(filename, final, 'utf8')

process.exit()
1 change: 1 addition & 0 deletions gen/hijri-calendar/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
20 changes: 12 additions & 8 deletions gen/hijri-calendar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,26 @@
* > 1936 and 2080 which should be sufficient for our needs
*/

var moment = require('moment-hijri')
const fs = require('fs')
const moment = require('moment-hijri')

var out = {}
const filename = `${__dirname}/../../src/internal/hijri-calendar.js`
const out = {}

// only years 1936 ... 2080 are supported by moment-hijri
for (let y = 1969; y <= 2080; y++) {
var iy = y - 580
const iy = y - 580

if (!out.year) {
out.year = iy
}
var iyy = iy - out.year
const iyy = iy - out.year

for (let im = 1; im <= 12; im++) {
var m = moment(iy + '/' + im + '/1', 'iYYYY/iM/iD')
const m = moment(iy + '/' + im + '/1', 'iYYYY/iM/iD')

var my = m.year()
var mm = m.iMonth()
const my = m.year()
const mm = m.iMonth()

if (!out[my]) {
out[my] = []
Expand All @@ -44,4 +46,6 @@ for (let y = 1969; y <= 2080; y++) {
}
}
}
console.log('/*eslint-disable*/\nmodule.exports=' + JSON.stringify(out).replace(/"/g, '')) // eslint-disable-line

const final = '/*eslint-disable*/\nmodule.exports=' + JSON.stringify(out).replace(/"/g, '')
fs.writeFileSync(filename, final, 'utf8')
2 changes: 1 addition & 1 deletion src/internal/hebrew-calendar.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/internal/hijri-calendar.js

Large diffs are not rendered by default.

0 comments on commit 0443a0f

Please sign in to comment.