Some checks failed
CI / go (push) Waiting to run
CI / docker (push) Waiting to run
CI / lint-go (push) Waiting to run
CI / lint-docs (push) Waiting to run
CI / check-paperclip (push) Waiting to run
Deploy static site / Deploy to GitHub Pages (push) Has been cancelled
Deploy static site / Deploy via Docker to hatch.surf (push) Has been cancelled
Resolved conflicts by taking GitHub versions for: - .dockerignore, .gitignore, Dockerfile, README.md, docker-compose.yml Kept deploy.sh updated to: - Pull from GitHub (primary source) - Push to Gitea (push-mirror) - Build from site/ directory (GitHub structure) Co-Authored-By: Paperclip <noreply@paperclip.ing>
53 lines
988 B
JavaScript
53 lines
988 B
JavaScript
'use strict';
|
|
|
|
var $EvalError = require('es-errors/eval');
|
|
|
|
var DayWithinYear = require('./DayWithinYear');
|
|
var InLeapYear = require('./InLeapYear');
|
|
var MonthFromTime = require('./MonthFromTime');
|
|
|
|
// https://262.ecma-international.org/5.1/#sec-15.9.1.5
|
|
|
|
module.exports = function DateFromTime(t) {
|
|
var m = MonthFromTime(t);
|
|
var d = DayWithinYear(t);
|
|
if (m === 0) {
|
|
return d + 1;
|
|
}
|
|
if (m === 1) {
|
|
return d - 30;
|
|
}
|
|
var leap = InLeapYear(t);
|
|
if (m === 2) {
|
|
return d - 58 - leap;
|
|
}
|
|
if (m === 3) {
|
|
return d - 89 - leap;
|
|
}
|
|
if (m === 4) {
|
|
return d - 119 - leap;
|
|
}
|
|
if (m === 5) {
|
|
return d - 150 - leap;
|
|
}
|
|
if (m === 6) {
|
|
return d - 180 - leap;
|
|
}
|
|
if (m === 7) {
|
|
return d - 211 - leap;
|
|
}
|
|
if (m === 8) {
|
|
return d - 242 - leap;
|
|
}
|
|
if (m === 9) {
|
|
return d - 272 - leap;
|
|
}
|
|
if (m === 10) {
|
|
return d - 303 - leap;
|
|
}
|
|
if (m === 11) {
|
|
return d - 333 - leap;
|
|
}
|
|
throw new $EvalError('Assertion failed: MonthFromTime returned an impossible value: ' + m);
|
|
};
|