django-vue3-admin-web/node_modules/date-chinese/lib/Korean.cjs
2025-10-20 21:21:14 +08:00

64 lines
1.5 KiB
JavaScript

'use strict';
var astronomia = require('astronomia');
var Chinese = require('./Chinese.cjs');
/**
* @copyright 2016 commenthol
* @license MIT
*/
// Start of Korean Calendar in 2333 BCE (단군기원 http://ko.wikipedia.org/wiki/단기)
const epochY = -2333;
const epoch = new astronomia.julian.CalendarGregorian(epochY, 1, 27).toJDE();
/**
* change of timezone shifts during the last century
* @see https://en.wikipedia.org/wiki/Time_in_South_Korea
*/
const UTC_DATES = [
{
date: new Date('1961-10-09T15:00:00.000Z'), // 1961-10-10T00:00:00+0900
shift: 9 / 24
}, // +9:00:00h (135° East)
{
date: new Date('1954-03-20T15:30:00.000Z'), // 1954-03-21T00:00:00+0830
shift: 8.5 / 24
},
{
date: new Date('1911-12-31T15:00:00.000Z'), // 1912-01-01T00:00:00+0900
shift: 9 / 24
},
{
date: new Date('1908-03-31T15:30:00.000Z'), // 1908-04-01T00:00:00+0830
shift: 8.5 / 24
}
];
class CalendarKorean extends Chinese {
constructor (cycle, year, month, leap, day) {
super(cycle, year, month, leap, day);
this._epochY = epochY;
this._epoch = epoch;
}
/**
* timeshift to UTC
*
* @param {CalendarGregorian} gcal - gregorian calendar date
* @return {Number} timeshift in fraction of day
*/
timeshiftUTC (gcal) {
const date = gcal.toDate();
for (const i in UTC_DATES) {
if (date >= UTC_DATES[i].date) {
return UTC_DATES[i].shift
}
}
return 3809 / 450 / 24 // +8:27:52h Seoul City Hall 126°58'E
}
}
module.exports = CalendarKorean;