summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Mönig <jens@moenig.org>2015-06-25 15:24:25 +0200
committerJens Mönig <jens@moenig.org>2015-06-25 15:24:25 +0200
commitc95347a6b0692a41e7e4ca1ef556e6002ac2ffce (patch)
tree5f78701d44bc6686712e7ca80c681b852d9987cf
parent8a7bc380a8df03f13133aae98654db6df51ccded (diff)
parent93d67ed386bba4862ac00eb55dcf664300ce53c7 (diff)
downloadsnap-c95347a6b0692a41e7e4ca1ef556e6002ac2ffce.tar.gz
snap-c95347a6b0692a41e7e4ca1ef556e6002ac2ffce.zip
Merge pull request #836 from cycomachead/date-error-fix
Fix Error Handing in the DATE block
-rw-r--r--threads.js30
1 files changed, 15 insertions, 15 deletions
diff --git a/threads.js b/threads.js
index 165ad0e..efe9ba4 100644
--- a/threads.js
+++ b/threads.js
@@ -2640,26 +2640,26 @@ Process.prototype.reportTimer = function () {
};
// 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) {
var inputFn = this.inputOption(datefn),
- currDate = new Date(),
- func = dateMap[inputFn],
- result = currDate[func]();
+ // Map block options to built-in functions
+ dateMap = {
+ 'year' : 'getFullYear',
+ 'month' : 'getMonth',
+ 'date': 'getDate',
+ 'day of week' : 'getDay',
+ 'hour' : 'getHours',
+ 'minute' : 'getMinutes',
+ 'second' : 'getSeconds',
+ 'time in milliseconds' : 'getTime'
+ };
if (!dateMap[inputFn]) { return ''; }
+ var currDate = new Date(),
+ func = dateMap[inputFn],
+ result = currDate[func]();
+
// Show months as 1-12 and days as 1-7
if (inputFn === 'month' || inputFn === 'day of week') {
result += 1;