Skip to content

Instantly share code, notes, and snippets.

View gregogalante's full-sized avatar
✌️
What's happening?

Gregorio Galante gregogalante

✌️
What's happening?
View GitHub Profile
function timeBetweenDates (dateTo, dateFrom) {
// get total seconds between the times
let delta = Math.abs(date_future - date_now) / 1000
// calculate (and subtract) whole days
let days = Math.floor(delta / 86400)
delta -= days * 86400
// calculate (and subtract) whole hours
let hours = Math.floor(delta / 3600) % 24
delta -= hours * 3600
// calculate (and subtract) whole minutes
@gregogalante
gregogalante / CustomArraySort.js
Last active August 30, 2018 10:33
CustomArraySort.js
/**
* @param {array} array
* @param {string} attribute
* @param {array} sortOrder
*/
function customArraySort (array, attribute, sortOrder) {
let ordering = {}
for (let i = 0; i < sortOrder.length; i++) {
ordering[sortOrder[i]] = i
}