Archived
1
0
Fork 0
This repository has been archived on 2024-02-06. You can view files and clone it, but cannot push or open issues or pull requests.
api-ts-gen/dist/utils/FullDate.js
supmiku39 75674df502 ClientAPI, ServerAPI interface, Schema TS codegen
ClientAPI: use Axios
ServerAPI: use @koa/router
FullDate: wrapped Date only class
APIPromise: enhanced Promise on api response

application/json only(multipart/*, image/*, ... are not supported)
get, post, put, delete, patch only
2020-04-05 00:57:34 +09:00

53 lines
1.8 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var FullDate = /** @class */ (function () {
function FullDate() {
var argv = [];
for (var _i = 0; _i < arguments.length; _i++) {
argv[_i] = arguments[_i];
}
this.date = (function () {
var _a;
if (argv.length == 1) {
var arg = argv[0];
if (arg instanceof FullDate)
return new Date(+arg);
if (arg instanceof Date)
return arg;
if (typeof arg === 'string') {
var tokens = (_a = /^(\d+)-(\d+)-(\d+)$/g.exec(arg)) === null || _a === void 0 ? void 0 : _a.slice(1, 4);
if (tokens)
return new Date(+tokens[0], +tokens[1] - 1, +tokens[2]);
}
return new Date(arg);
}
else if (argv.length == 3) {
return new Date(argv[0], argv[1] - 1, argv[2]);
}
return new Date();
})();
}
FullDate.prototype.toString = function () {
var d = this.date;
var f = function (s) { return ('0' + s).slice(-2); };
return d.getFullYear() + "-" + f(d.getMonth() + 1) + "-" + f(d.getDate());
};
FullDate.prototype.toJSON = function () {
return this.toString();
};
FullDate.prototype.valueOf = function () {
return new Date(this.date).setHours(0, 0, 0, 0);
};
// prop
FullDate.prototype.getFullYear = function () {
return this.date.getFullYear();
};
FullDate.prototype.getMonth = function () {
return this.date.getMonth() + 1;
};
FullDate.prototype.getDate = function () {
return this.date.getDate();
};
return FullDate;
}());
exports.FullDate = FullDate;