Skip to content

Instantly share code, notes, and snippets.

@bloodyowl
Created October 31, 2012 13:54
Show Gist options
  • Save bloodyowl/3987147 to your computer and use it in GitHub Desktop.
Save bloodyowl/3987147 to your computer and use it in GitHub Desktop.
Date unificator
// var dateFormat -> something returning a date like "YYYY/MM/DD", "DD-MM-YYYY", "MM/DD/YYYY" ...
// Function#curry from Craft.js
// https://github.com/mlbli/Craft/
var convertDate = (function(string, date){
var year = string.indexOf("Y"),
month = string.indexOf("M"),
day = string.indexOf("D")
return [date.slice(year, year + 4), date.slice(month, month + 2), date.slice(day, day + 2)].join("-")
}).curry(dateFormat)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment