Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function getSolarTermForTime(time) {
const calendarChinese = new CalendarChinese();
for (let i = 0; i < 24; ++i) {
const dateObject = calendarChinese.fromJDE(calendarChinese.solarTerm(i + 1, time.year())).toGregorian();
const date = moment({
year: dateObject.year,
month: dateObject.month - 1,
day : dateObject.day
}).tz(timezone);
if (date.isSame(time, 'day')) {
return SOLAR_TERM_NAMES[i];
}
}
return null;
}
constructor (opts) {
opts = opts || {}
super(opts)
switch (opts.fn) {
case 'chinese':
this.cal = new CalChinese.CalendarChinese()
break
case 'korean':
this.cal = new CalChinese.CalendarKorean()
break
case 'vietnamese':
this.cal = new CalChinese.CalendarVietnamese()
break
}
}