JSFiddle - React, Tailwind, and code Playground
by Cwalkdawg
JavaScript
/**
* Check if value is in an array.
* @param {object} val Can be any object. The is this value to check against the array
* @return {boolean} Returns true if value is in array. Returns false if not
*/
Array.prototype.inArray = function (val) {
"use strict";
var flag = false; //return flag (boolean)
var i; // iterator
for (i = 0; i < this.length; i++) {
if (this[i] === val) {
flag = true;
}
}
return flag;
};
console.clear();
var DateTime = {
//If you can't understand this, you shouldn't be messing with this script
days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
//this part too
months: ["January", "February", "March", "April", "May", "June", "July",
"August", "September", "October", "November", "December"],
//DateTime date object, call with this.D within DateTime, call with DateTime.D outside
d: new Date(),
/**
* Get the time for when the function is called.
* @param {String} format Parameter will be used for either grabbing the current number of milliseconds since 1/1/1970 (useful
* for determining specific execution times) or the human readable form of now at the computer's local
* time (i.e. 09:25:35) in 24 hour time.
* Options are "human" for human-readable and "exec" for milliseconds
* Default is exec
*/
now: function (format) {
var ret; // return value
if (format === "" || !format) {
format = "exec";
} else {
format = format.toLowerCase();
}
if (format !== "human" && format !== "exec") {
format = "exec";
}
if (format === "human") {
ret = this.d.getHours() + ":" + this.d.getMinutes() + ":" + this.d.getSeconds();
} else if (format === "exec") {
ret = this.d.getTime();
...