Skip to content

Commit

Permalink
Better time handling
Browse files Browse the repository at this point in the history
  • Loading branch information
William committed Apr 26, 2016
1 parent 97342b5 commit 18ba5c0
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions utils.cfc
Expand Up @@ -39,21 +39,20 @@ component {
cfcookie(name=arguments.name, value=arguments.value, domain=".cfpm.io", expires=arguments.time, path='/');
}

function generateToken(){
var string = CreateUUID();
var token = Hash(string, 'SHA-512');
return token;
}

function time(time=''){
function time(time='', format=''){
if(time == ''){
return DateDiff("s", CreateDate(1970,1,1), Now());
}
if(IsValid('integer', time)){
var date = DateAdd("s", time, CreateDateTime(1970, 1, 1, 0, 0, 0));
if(format != ''){
format = format == true ? 'short' : format;
return dateTimeFormat(date, format);
}
return date;
}
if(IsValid('time', time)){
return DateDiff("s", CreateDate(1970,1,1), time);
}
if(IsValid('integer', time)){
DateAdd("s", time, CreateDateTime(1970, 1, 1, 0, 0, 0));
}
}
}

0 comments on commit 18ba5c0

Please sign in to comment.