Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let jde
switch (this._season) {
case 'march': {
jde = solstice.march2(year, earth)
break
}
case 'june': {
jde = solstice.june2(year, earth)
break
}
case 'september': {
jde = solstice.september2(year, earth)
break
}
case 'december': {
jde = solstice.december2(year, earth)
break
}
}
const str = new julian.Calendar().fromJDE(jde).toDate().toISOString()
let date
if (/^[+-]\d{2}:\d{2}?$/.test(this._timezone)) { // for '+08:00' formats
date = moment(str).utcOffset(this._timezone)
} else { // for 'Asia/Shanghai' formats
date = moment(str).tz(this._timezone) // move to timezone
}
const floorDate = {
year: year,
month: date.month() + 1,
day: date.date()
newYear (gyear) {
gyear = Math.trunc(gyear)
if (this._cache.ny[gyear]) return this._cache.ny[gyear]
const sue1 = this._cache.sue[gyear - 1] || solstice.december2(gyear - 1, earth)
const sue2 = this._cache.sue[gyear] || solstice.december2(gyear, earth)
this._cache.sue[gyear - 1] = sue1
this._cache.sue[gyear] = sue2
const m11n = this.previousNewMoon(this.midnight(sue2 + 1))
const m12 = this.nextNewMoon(this.midnight(sue1 + 1))
const m13 = this.nextNewMoon(this.midnight(m12 + lunarOffset))
this.leapSui = Math.round((m11n - m12) / moonphase.meanLunarMonth) === 12
let ny = m13
if (this.leapSui && (this.isLeapMonth(m12) || this.isLeapMonth(m13))) {
ny = this.nextNewMoon(this.midnight(m13 + moonphase.meanLunarMonth / 2))
}
this._cache.ny[gyear] = ny
return ny
}
newYear (gyear) {
gyear = Math.trunc(gyear)
if (this._cache.ny[gyear]) return this._cache.ny[gyear]
const sue1 = this._cache.sue[gyear - 1] || solstice.december2(gyear - 1, earth)
const sue2 = this._cache.sue[gyear] || solstice.december2(gyear, earth)
this._cache.sue[gyear - 1] = sue1
this._cache.sue[gyear] = sue2
const m11n = this.previousNewMoon(this.midnight(sue2 + 1))
const m12 = this.nextNewMoon(this.midnight(sue1 + 1))
const m13 = this.nextNewMoon(this.midnight(m12 + lunarOffset))
this.leapSui = Math.round((m11n - m12) / moonphase.meanLunarMonth) === 12
let ny = m13
if (this.leapSui && (this.isLeapMonth(m12) || this.isLeapMonth(m13))) {
ny = this.nextNewMoon(this.midnight(m13 + moonphase.meanLunarMonth / 2))
}
this._cache.ny[gyear] = ny
return ny
}
value: function newYear(gyear) {
gyear = Math.trunc(gyear);
if (this._cache.ny[gyear]) return this._cache.ny[gyear];
var sue1 = this._cache.sue[gyear - 1] || solstice.december2(gyear - 1, earth);
var sue2 = this._cache.sue[gyear] || solstice.december2(gyear, earth);
this._cache.sue[gyear - 1] = sue1;
this._cache.sue[gyear] = sue2;
var m11n = this.previousNewMoon(this.midnight(sue2 + 1));
var m12 = this.nextNewMoon(this.midnight(sue1 + 1));
var m13 = this.nextNewMoon(this.midnight(m12 + lunarOffset));
this.leapSui = Math.round((m11n - m12) / moonphase.meanLunarMonth) === 12;
var ny = m13;
if (this.leapSui && (this.isLeapMonth(m12) || this.isLeapMonth(m13))) {
ny = this.nextNewMoon(this.midnight(m13 + moonphase.meanLunarMonth / 2));
}
this._cache.ny[gyear] = ny;
return ny;
}
value: function newYear(gyear) {
gyear = Math.trunc(gyear);
if (this._cache.ny[gyear]) return this._cache.ny[gyear];
var sue1 = this._cache.sue[gyear - 1] || solstice.december2(gyear - 1, earth);
var sue2 = this._cache.sue[gyear] || solstice.december2(gyear, earth);
this._cache.sue[gyear - 1] = sue1;
this._cache.sue[gyear] = sue2;
var m11n = this.previousNewMoon(this.midnight(sue2 + 1));
var m12 = this.nextNewMoon(this.midnight(sue1 + 1));
var m13 = this.nextNewMoon(this.midnight(m12 + lunarOffset));
this.leapSui = Math.round((m11n - m12) / moonphase.meanLunarMonth) === 12;
var ny = m13;
if (this.leapSui && (this.isLeapMonth(m12) || this.isLeapMonth(m13))) {
ny = this.nextNewMoon(this.midnight(m13 + moonphase.meanLunarMonth / 2));
}
this._cache.ny[gyear] = ny;
return ny;
}