Skip to content

Commit

Permalink
### 3.6.5 (2019-02-13)
Browse files Browse the repository at this point in the history
* (bluefox) Error with formatDate was fixed
  • Loading branch information
GermanBluefox committed Feb 13, 2019
1 parent d28b8a8 commit 786db14
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 13 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ Hier kann man die Beschreibung von [Blockly](doc/de/blockly.md) finden.
Описание по [blockly](doc/ru/blockly.md) можно найти [здесь](doc/ru/blockl.md).

## Changelog
### 3.6.5 (2019-02-13)
* (bluefox) Error with formatDate was fixed

### 3.6.4 (2018-02-05)
* (bluefox) Pattern error is fixed

Expand Down
14 changes: 13 additions & 1 deletion io-package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"common": {
"name": "javascript",
"version": "3.6.4",
"version": "3.6.5",
"title": "Script Engine",
"titleLang": {
"en": "Script Engine",
Expand All @@ -20,6 +20,18 @@
"Apollon77 <[email protected]>"
],
"news": {
"3.6.5": {
"en": "Error with formatDate was fixed",
"de": "Fehler bei formatDate wurde behoben",
"ru": "Ошибка с formatDate была исправлена",
"pt": "Erro com formatDate foi corrigido",
"nl": "Fout met formatDate is opgelost",
"fr": "Erreur avec formatDate a été corrigé",
"it": "Errore con formatDate risolto",
"es": "El error con formatDate fue corregido",
"pl": "Naprawiono błąd z formatDate",
"zh-cn": "修复了formatDate的错误"
},
"3.6.4": {
"en": "Pattern error is fixed",
"de": "Musterfehler ist behoben",
Expand Down
56 changes: 45 additions & 11 deletions javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,9 @@

if (id === 'system.config') {
// set langugae for debug messages
if (objects['system.config'].common.language) words.setLanguage(objects['system.config'].common.language);
if (objects['system.config'].common && objects['system.config'].common.language) {
words.setLanguage(objects['system.config'].common.language);
}
}

return;
Expand Down Expand Up @@ -2697,19 +2699,37 @@
script.onStopTimeout = timeout || 1000;
},
formatValue: function (value, decimals, format) {
if (!format && objects['system.config']) {
format = objects['system.config'].common.isFloatComma ? '.,' : ',.';
if (!format) {
if (adapter.isFloatComma !== undefined) {
format = adapter.isFloatComm ? '.,' : ',.';
} else if (objects['system.config'] && objects['system.config'].common) {
format = objects['system.config'].common.isFloatComma ? '.,' : ',.';
}
}
return adapter.formatValue(value, decimals, format);
},

formatDate: function (date, format, language) {
if (!format) {
format = objects['system.config'] ? (objects['system.config'].common.dateFormat || 'DD.MM.YYYY') : 'DD.MM.YYYY';
if (adapter.dateFormat) {
format = adapter.dateFormat;
} else if (objects['system.config'] && objects['system.config'].common) {
format = objects['system.config'] ? (objects['system.config'].common.dateFormat || 'DD.MM.YYYY') : 'DD.MM.YYYY';
}
format = format || 'DD.MM.YYYY';
}
if (format.match(/W|Н|O|О/)) {
var text = adapter.formatDate(date, format);
if (!language || !dayOfWeeksFull[language]) language = objects['system.config'].common.language;
if (!language || !dayOfWeeksFull[language]) {
if (adapter.language) {
language = adapter.language;
} else {
language = objects['system.config'] && objects['system.config'].common && objects['system.config'].common.language;
}
if (!dayOfWeeksFull[language]) {
language = 'de';
}
}
var d = date.getDay();
text = text.replace('WW', dayOfWeeksFull[language][d]);
text = text.replace('НН', dayOfWeeksFull[language][d]);
Expand Down Expand Up @@ -2826,7 +2846,11 @@
var timeoutMs = parseInt(options.timeout, 10) || 20000;

if (!instance) {
instance = objects['system.config'] ? objects['system.config'].common.defaultHistory : null;
if (adapter.defaultHistory) {
instance = adapter.defaultHistory;
} else {
instance = objects['system.config'] && objects['system.config'].common ? objects['system.config'].common.defaultHistory : null;
}
}

if (sandbox.verbose) sandbox.log('getHistory(instance=' + instance + ', options=' + JSON.stringify(options) + ')', 'debug');
Expand Down Expand Up @@ -3327,14 +3351,24 @@
}
addGetProperty(objects);

var systemConfig = objects['system.config'];

// set language for debug messages
if (objects['system.config'] && objects['system.config'].common.language) words.setLanguage(objects['system.config'].common.language);
if (systemConfig && systemConfig.common && systemConfig.common.language) {
words.setLanguage(systemConfig.common.language);
} else if (adapter.language) {
words.setLanguage(adapter.language);
}

// try to use system coordinates
if (adapter.config.useSystemGPS && objects['system.config'] &&
objects['system.config'].common.latitude) {
adapter.config.latitude = objects['system.config'].common.latitude;
adapter.config.longitude = objects['system.config'].common.longitude;
if (adapter.config.useSystemGPS) {
if (systemConfig && systemConfig.common && systemConfig.common.latitude) {
adapter.config.latitude = systemConfig.common.latitude;
adapter.config.longitude = systemConfig.common.longitude;
} else if (adapter.latitude) {
adapter.config.latitude = adapter.latitude;
adapter.config.longitude = adapter.longitude;
}
}
adapter.config.latitude = parseFloat(adapter.config.latitude);
adapter.config.longitude = parseFloat(adapter.config.longitude);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "iobroker.javascript",
"version": "3.6.4",
"version": "3.6.5",
"description": "Javascript/Coffescript Script Engine for ioBroker",
"author": "bluefox <[email protected]>",
"contributors": [
Expand Down

0 comments on commit 786db14

Please sign in to comment.