UNPKG

1.73 kBJavaScriptView Raw
1/*!
2 * Copyright 2016 Amazon.com,
3 * Inc. or its affiliates. All Rights Reserved.
4 *
5 * Licensed under the Amazon Software License (the "License").
6 * You may not use this file except in compliance with the
7 * License. A copy of the License is located at
8 *
9 * http://aws.amazon.com/asl/
10 *
11 * or in the "license" file accompanying this file. This file is
12 * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
13 * CONDITIONS OF ANY KIND, express or implied. See the License
14 * for the specific language governing permissions and
15 * limitations under the License.
16 */
17var monthNames = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
18var weekNames = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
19/** @class */
20
21var DateHelper = /*#__PURE__*/function () {
22 function DateHelper() {}
23
24 var _proto = DateHelper.prototype;
25
26 /**
27 * @returns {string} The current time in "ddd MMM D HH:mm:ss UTC YYYY" format.
28 */
29 _proto.getNowString = function getNowString() {
30 var now = new Date();
31 var weekDay = weekNames[now.getUTCDay()];
32 var month = monthNames[now.getUTCMonth()];
33 var day = now.getUTCDate();
34 var hours = now.getUTCHours();
35
36 if (hours < 10) {
37 hours = "0" + hours;
38 }
39
40 var minutes = now.getUTCMinutes();
41
42 if (minutes < 10) {
43 minutes = "0" + minutes;
44 }
45
46 var seconds = now.getUTCSeconds();
47
48 if (seconds < 10) {
49 seconds = "0" + seconds;
50 }
51
52 var year = now.getUTCFullYear(); // ddd MMM D HH:mm:ss UTC YYYY
53
54 var dateNow = weekDay + " " + month + " " + day + " " + hours + ":" + minutes + ":" + seconds + " UTC " + year;
55 return dateNow;
56 };
57
58 return DateHelper;
59}();
60
61export { DateHelper as default };
\No newline at end of file