summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Ball <cycomachead@gmail.com>2013-12-27 18:49:56 -0800
committerMichael Ball <cycomachead@gmail.com>2013-12-27 18:49:56 -0800
commitfaa8b4fe2243b1a8ef5cc4342183f4880b728a3d (patch)
treef158b1b8c6a3b7c0923ba0660f1fca4ba4c55635
parente9020b4ed3f7190dc78e622fbe3b2665e227c30f (diff)
downloadsnap-yow-faa8b4fe2243b1a8ef5cc4342183f4880b728a3d.tar.gz
snap-yow-faa8b4fe2243b1a8ef5cc4342183f4880b728a3d.zip
Add a 'get current DATE' block with various options, add some translations to FR and DE
-rw-r--r--blocks.js26
-rw-r--r--lang-de.js43
-rw-r--r--lang-fr.js52
-rw-r--r--objects.js14
-rw-r--r--threads.js58
5 files changed, 184 insertions, 9 deletions
diff --git a/blocks.js b/blocks.js
index 96d8b53..ed936d1 100644
--- a/blocks.js
+++ b/blocks.js
@@ -155,7 +155,7 @@ DialogBoxMorph, BlockInputFragmentMorph, PrototypeHatBlockMorph, Costume*/
// Global stuff ////////////////////////////////////////////////////////
-modules.blocks = '2013-November-26';
+modules.blocks = '2013-December-27';
var SyntaxElementMorph;
var BlockMorph;
@@ -812,6 +812,27 @@ SyntaxElementMorph.prototype.labelPart = function (spec) {
true // read-only
);
break;
+ case '%dates':
+ part = new InputSlotMorph(
+ null, // text
+ false, // non-numeric
+ {
+ 'Date' : ['Date'],
+ 'Month' : ['Month'],
+ 'Day of Month' : ['Day of Month'],
+ 'Year' : ['Year'],
+ 'Day of Week' : ['Day of Week'],
+ 'Time' : ['Time'],
+ 'Hour' : ['Hour'],
+ 'Minute' : ['Minute'],
+ 'Second' : ['Second'],
+ 'Time in Milliseconds' : ['Time in Milliseconds'],
+ 'UTC Time' : ['UTC Time'],
+ },
+ true // read-only
+ );
+ part.setContents('Date')
+ break;
case '%delim':
part = new InputSlotMorph(
null, // text
@@ -1166,7 +1187,6 @@ SyntaxElementMorph.prototype.labelPart = function (spec) {
);
break;
-
// symbols:
case '%turtle':
@@ -6147,7 +6167,7 @@ CSlotMorph.prototype.drawBottomEdge = function (context) {
I am an editable text input slot. I can be either rectangular or
rounded, and can have an optional drop-down menu. If I'm set to
read-only I must have a drop-down menu and will assume a darker
- shade of my parent's color.
+ shade of my parent's color.
my most important public attributes and accessors are:
diff --git a/lang-de.js b/lang-de.js
index dec6092..e234d67 100644
--- a/lang-de.js
+++ b/lang-de.js
@@ -1246,4 +1246,47 @@ SnapTranslator.dict.de = {
'letztes',
'any':
'beliebiges'
+
+ // Date reporter dropdowns
+ 'Month':
+ 'Monat',
+ // Months of the Year
+ 'January':
+ 'Januar',
+ 'February':
+ 'Februar',
+ 'March':
+ 'März',
+ 'April':
+ 'April';
+ 'May':
+ 'Mai',
+ 'June':
+ 'Juni',
+ 'July':
+ 'Juli';
+ 'August':
+ 'August',
+ 'September':
+ 'September',
+ 'October':
+ 'Oktober';
+ 'November':
+ 'November',
+ 'December':
+ 'Dezember',
+ 'Sunday':
+ 'Sonntag';
+ 'Monday':
+ 'Montag',
+ 'Tuesday':
+ 'Dienstag',
+ 'Wednesday':
+ 'Mittwoch';
+ 'Thursday':
+ 'Donnerstag',
+ 'Friday':
+ 'Freitag',
+ 'Saturday':
+ 'Samstag';
};
diff --git a/lang-fr.js b/lang-fr.js
index 8fd9cc7..def94bf 100644
--- a/lang-fr.js
+++ b/lang-fr.js
@@ -716,7 +716,7 @@ SnapTranslator.dict.fr = {
'check for alternative\nGUI design':
'Cocher pour un style d\interface alternatif',
'uncheck for default\nGUI design':
- 'D\u00E9cocher pour le style classique d\interface',
+ 'D\u00E9cocher pour le style classique d\interface',
'Thread safe scripts':
'Scripts réentrants',
'check to disallow\nscript reentrance':
@@ -731,7 +731,7 @@ SnapTranslator.dict.fr = {
'D\u00E9cocher pour une vitesse\nd\'animation maximale (mais variable)',
'check for smooth, predictable\nanimations across computers':
'Cocher pour une vitesse d\'animation\nfixe et identique sur tous les ordinateurs',
-
+
// inputs
'with inputs':
'avec entr\u00E9es',
@@ -956,7 +956,7 @@ SnapTranslator.dict.fr = {
'tabulations',
'cr':
'retours de ligne',
-
+
// About Snap
'About Snap':
'A propos de Snap',
@@ -1160,5 +1160,49 @@ SnapTranslator.dict.fr = {
'last':
'dernier',
'any':
- 'n\u0027importe quel'
+ 'n\u0027importe quel',
+
+ // Date reporter dropdowns
+ 'Month':
+ 'mois',
+ // Months of the Year
+ 'January':
+ 'janvier',
+ 'February':
+ 'février',
+ 'March':
+ 'mars',
+ 'April':
+ 'avril';
+ 'May':
+ 'mai',
+ 'June':
+ 'juin',
+ 'July':
+ 'juillet';
+ 'August':
+ 'août',
+ 'September':
+ 'septembre',
+ 'October':
+ 'octobre';
+ 'November':
+ 'novembre',
+ 'December':
+ 'decembre',
+ 'Sunday':
+ 'dimanche';
+ 'Monday':
+ 'lundi',
+ 'Tuesday':
+ 'mardi',
+ 'Wednesday':
+ 'mercredi';
+ 'Thursday':
+ 'jedui',
+ 'Friday':
+ 'vendredi',
+ 'Saturday':
+ 'samedi';
+
};
diff --git a/objects.js b/objects.js
index 41b511d..a2caedd 100644
--- a/objects.js
+++ b/objects.js
@@ -124,7 +124,7 @@ PrototypeHatBlockMorph*/
// Global stuff ////////////////////////////////////////////////////////
-modules.objects = '2013-December-19';
+modules.objects = '2013-December-27';
var SpriteMorph;
var StageMorph;
@@ -786,6 +786,12 @@ SpriteMorph.prototype.initBlocks = function () {
category: 'sensing',
spec: 'set turbo mode to %b'
},
+ reportDate: {
+ type: 'reporter',
+ category: 'sensing',
+ spec: 'get current %dates',
+
+ },
// Operators
reifyScript: {
@@ -1700,6 +1706,8 @@ SpriteMorph.prototype.blockTemplates = function (category) {
blocks.push('-');
blocks.push(block('reportIsFastTracking'));
blocks.push(block('doSetFastTracking'));
+ blocks.push('-');
+ blocks.push(block('reportDate'));
// for debugging: ///////////////
@@ -4398,6 +4406,8 @@ StageMorph.prototype.blockTemplates = function (category) {
blocks.push('-');
blocks.push(block('reportIsFastTracking'));
blocks.push(block('doSetFastTracking'));
+ blocks.push('-');
+ blocks.push(block('reportDate'));
// for debugging: ///////////////
@@ -5147,7 +5157,7 @@ Costume.prototype.shrinkWrap = function () {
};
Costume.prototype.boundingBox = function () {
- // answer the rectangle surrounding my contents' non-transparent pixels
+ // answer the rectangle surrounding my contents' non-transparent pixels
var row,
col,
pic = this.contents,
diff --git a/threads.js b/threads.js
index d1e57d3..13fcff3 100644
--- a/threads.js
+++ b/threads.js
@@ -2474,6 +2474,34 @@ Process.prototype.reportTimer = function () {
return 0;
};
+// Process Dates and times in Snap
+
+Process.prototype.reportDate = function (datefn) {
+ // Map block options to built-in functions
+ var dateMap = { 'Date' : 'toLocaleDateString',
+ 'Time' : 'toLocaleTimeString',
+ 'Month' : 'getMonthName', // return a name, not a number
+ 'Day of Week' : 'getDayName', // return a name, not a number
+ 'Day of Month': 'getDate',
+ 'Year' : 'getFullYear',
+ 'Hour' : 'getHours',
+ 'Minute' : 'getMinutes',
+ 'Second' : 'getSeconds',
+ 'Milliseconds' : 'getMilliseconds',
+ 'Time in Milliseconds' : 'getTime',
+ 'UTC Time' : 'toUTCString' };
+
+ if (!dateMap[datefn]) {
+ return '';
+ }
+
+ currDate = new Date();
+ func = dateMap[datefn]
+
+ return currDate[func]();
+
+}
+
// Process code mapping
/*
@@ -3068,3 +3096,33 @@ UpvarReference.prototype.toString = function () {
UpvarReference.prototype.names = VariableFrame.prototype.names;
UpvarReference.prototype.allNames = VariableFrame.prototype.allNames;
UpvarReference.prototype.allNamesDict = VariableFrame.prototype.allNamesDict;
+
+// Date Utilities (for the 'reportDate' block)
+
+Date.prototype.getMonthName = function () {
+ mons = ['January',
+ 'February',
+ 'March',
+ 'April',
+ 'May',
+ 'June',
+ 'July',
+ 'August',
+ 'September',
+ 'October',
+ 'November',
+ 'December'];
+ return localize(mons[this.getMonth()]);
+}
+
+Date.prototype.getDayName = function () {
+ days = ['Sunday',
+ 'Monday',
+ 'Tuesday',
+ 'Wednesday',
+ 'Thursday',
+ 'Friday',
+ 'Saturday'];
+ return localize(days[this.getDay()]);
+}
+