This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function(doc){ | |
// handle a custom format using methods in the date object | |
var format = "{getFullYear}/{getMonth}/{getDate}", | |
date = new Date(doc.created_at), | |
// use a regular expression to replace parts of our format string | |
formatted_date = format.replace(/\{(\w+)\}/g, function(str, func){ | |
var time = date[func](); | |
// if `func` is `getMonth` we must offset by one | |
if(func === 'getMonth'){ | |
time += 1; |