This repository was archived by the owner on Dec 9, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathDateUtil.js
104 lines (104 loc) · 3.31 KB
/
DateUtil.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
(function (factory) {
if (typeof module === "object" && typeof module.exports === "object") {
var v = factory(require, exports);
if (v !== undefined) module.exports = v;
}
else if (typeof define === "function" && define.amd) {
define(["require", "exports"], factory);
}
})(function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
* A helper class that deals with dates.
*
* @class DateUtil
* @module StructureJS
* @submodule util
* @author Robert S. (www.codeBelt.com)
* @static
*/
var DateUtil = (function () {
function DateUtil() {
throw new Error('[DateUtil] Do not instantiate the DateUtil class because it is a static class.');
}
/**
* Returns the suffix of a given day.
*
* @method getDaySuffix
* @param today {number}
* @returns {string}
* @public
* @static
* @example
* DateUtil.getDaySuffix(1);
* // 'st'
*
* DateUtil.getDaySuffix(2);
* // 'nd'
*
* DateUtil.getDaySuffix(3);
* // 'rd'
*
* DateUtil.getDaySuffix(4);
* // 'th'
*/
DateUtil.getDaySuffix = function (today) {
var day = today % 100;
return ((Math.floor(day / 10) === 1) ? 'th' : ['th', 'st', 'nd', 'rd', 'th', 'th', 'th', 'th', 'th', 'th'][day % 10]);
};
return DateUtil;
}());
/**
* A list of day names.
*
* @property LONG_DAY_LABELS
* @type [Array=['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']]
* @public
* @static
* @final
* @example
* DateUtil.LONG_DAY_LABELS[1];
* // 'Monday'
*/
DateUtil.LONG_DAY_LABELS = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
/**
* A list of short day names
*
* @property SHORT_DAY_LABELS
* @type [Array=['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']]
* @public
* @static
* @final
* @example
* DateUtil.SHORT_DAY_LABELS[1];
* // 'Mon'
*/
DateUtil.SHORT_DAY_LABELS = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
/**
* A list of month names.
*
* @property LONG_MONTH_LABELS
* @type [Array=['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']]
* @public
* @static
* @final
* @example
* DateUtil.LONG_MONTH_LABELS[1];
* // 'February'
*/
DateUtil.LONG_MONTH_LABELS = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
/**
* A list of short month names.
*
* @property SHORT_MONTH_LABELS
* @type [Array=['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']]
* @public
* @final
* @example
* DateUtil.SHORT_MONTH_LABELS[1];
* // 'Feb'
*/
DateUtil.SHORT_MONTH_LABELS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
exports.default = DateUtil;
});