diff options
Diffstat (limited to 'threads.js')
| -rw-r--r-- | threads.js | 29 |
1 files changed, 28 insertions, 1 deletions
@@ -111,7 +111,7 @@ function snapEquals(a, b) { y = b; } - // handle text comparision text-insensitive. + // handle text comparision case-insensitive. if (isString(x) && isString(y)) { return x.toLowerCase() === y.toLowerCase(); } @@ -2536,6 +2536,33 @@ Process.prototype.reportTimer = function () { return 0; }; +// Process Dates and times in Snap +// Map block options to built-in functions +var dateMap = { + 'year' : 'getFullYear', + 'month' : 'getMonth', + 'date': 'getDate', + 'day of week' : 'getDay', + 'hour' : 'getHours', + 'minute' : 'getMinutes', + 'second' : 'getSeconds', + 'time in milliseconds' : 'getTime' }; + +Process.prototype.reportDate = function (datefn) { + if (!dateMap[datefn]) { return ''; } + + currDate = new Date(); + func = dateMap[datefn]; + result = currDate[func](); + + // Show months as 1-12 and days as 1-7 + if (datefn === 'month' || datefn === 'day of week') { + result += 1; + } + + return result; +} + // Process code mapping /* |
