Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
value: function fromJDE(jde) {
var j = this.midnight(jde);
var gc = new julian.CalendarGregorian().fromJDE(j);
if (gc.month === 1 && gc.day < 20) gc.year--; // chinese new year never starts before 20/01
this._from(j, gc.year);
return this;
}
fromJDE (jde) {
const j = this.midnight(jde)
const gc = new julian.CalendarGregorian().fromJDE(j)
if (gc.month === 1 && gc.day < 20) gc.year-- // chinese new year never starts before 20/01
this._from(j, gc.year)
return this
}
value: function fromGregorian(year, month, day) {
var j = this.midnight(new julian.CalendarGregorian(year, month, day).toJDE());
if (month === 1 && day <= 20) year--; // chinese new year never starts before 20/01
this._from(j, year);
return this;
}
function toYear (jde) {
return new julian.CalendarGregorian().fromJDE(jde).toYear()
}
fromDate (date) {
const j = this.midnight(new julian.CalendarGregorian().fromDate(date).toJDE())
this._from(j, date.getFullYear())
return this
}
midnight (jde) {
const gcal = new julian.CalendarGregorian().fromJDE(jde)
const ts = 0.5 - this.timeshiftUTC(gcal)
let mn = Math.trunc(gcal.toJD() - ts) + ts
mn = gcal.fromJD(mn).toJDE()
if (toFixed(jde, 5) === toFixed(mn, 5) + 1) {
return jde
}
return mn
}
function toYear(jde) {
return new julian.CalendarGregorian().fromJDE(jde).toYear();
}