aboutsummaryrefslogtreecommitdiffstats
path: root/node_modules/date-fns/formatRFC7231/index.js
diff options
context:
space:
mode:
authorPinapelz <yukais@pinapelz.com>2025-06-28 17:26:46 -0700
committerPinapelz <yukais@pinapelz.com>2025-06-28 17:43:56 -0700
commite4fa1e69e7ebfb627c7198fd1a9881e9327ec4d4 (patch)
tree06284a538a6008eca75051399e47db4e5d50301c /node_modules/date-fns/formatRFC7231/index.js
initial commit: scaffolding
Diffstat (limited to 'node_modules/date-fns/formatRFC7231/index.js')
-rw-r--r--node_modules/date-fns/formatRFC7231/index.js52
1 files changed, 52 insertions, 0 deletions
diff --git a/node_modules/date-fns/formatRFC7231/index.js b/node_modules/date-fns/formatRFC7231/index.js
new file mode 100644
index 0000000..d7ce57d
--- /dev/null
+++ b/node_modules/date-fns/formatRFC7231/index.js
@@ -0,0 +1,52 @@
+"use strict";
+
+var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = formatRFC7231;
+var _index = _interopRequireDefault(require("../toDate/index.js"));
+var _index2 = _interopRequireDefault(require("../isValid/index.js"));
+var _index3 = _interopRequireDefault(require("../_lib/addLeadingZeros/index.js"));
+var days = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
+var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
+
+/**
+ * @name formatRFC7231
+ * @category Common Helpers
+ * @summary Format the date according to the RFC 7231 standard (https://tools.ietf.org/html/rfc7231#section-7.1.1.1).
+ *
+ * @description
+ * Return the formatted date string in RFC 7231 format.
+ * The result will always be in UTC timezone.
+ *
+ * @param {Date|Number} date - the original date
+ * @returns {String} the formatted date string
+ * @throws {TypeError} 1 argument required
+ * @throws {RangeError} `date` must not be Invalid Date
+ *
+ * @example
+ * // Represent 18 September 2019 in RFC 7231 format:
+ * const result = formatRFC7231(new Date(2019, 8, 18, 19, 0, 52))
+ * //=> 'Wed, 18 Sep 2019 19:00:52 GMT'
+ */
+function formatRFC7231(dirtyDate) {
+ if (arguments.length < 1) {
+ throw new TypeError("1 arguments required, but only ".concat(arguments.length, " present"));
+ }
+ var originalDate = (0, _index.default)(dirtyDate);
+ if (!(0, _index2.default)(originalDate)) {
+ throw new RangeError('Invalid time value');
+ }
+ var dayName = days[originalDate.getUTCDay()];
+ var dayOfMonth = (0, _index3.default)(originalDate.getUTCDate(), 2);
+ var monthName = months[originalDate.getUTCMonth()];
+ var year = originalDate.getUTCFullYear();
+ var hour = (0, _index3.default)(originalDate.getUTCHours(), 2);
+ var minute = (0, _index3.default)(originalDate.getUTCMinutes(), 2);
+ var second = (0, _index3.default)(originalDate.getUTCSeconds(), 2);
+
+ // Result variables.
+ return "".concat(dayName, ", ").concat(dayOfMonth, " ").concat(monthName, " ").concat(year, " ").concat(hour, ":").concat(minute, ":").concat(second, " GMT");
+}
+module.exports = exports.default; \ No newline at end of file
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage