Merge pull request #1897 from ONLYOFFICE/fix/bugfix
Fix date.toLocaleString for invalid language
This commit is contained in:
commit
1595ba125b
|
@ -1525,8 +1525,15 @@ define([
|
|||
this.coreProps = (this.api) ? this.api.asc_getCoreProps() : null;
|
||||
if (this.coreProps) {
|
||||
var value = this.coreProps.asc_getCreated();
|
||||
if (value)
|
||||
this.lblDate.text(value.toLocaleString(this.mode.lang, {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' + value.toLocaleString(this.mode.lang, {timeStyle: 'short'}));
|
||||
if (value) {
|
||||
var lang = (this.mode.lang || 'en').replace('_', '-').toLowerCase();
|
||||
try {
|
||||
this.lblDate.text(value.toLocaleString(lang, {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' + value.toLocaleString(lang, {timeStyle: 'short'}));
|
||||
} catch (e) {
|
||||
lang = 'en';
|
||||
this.lblDate.text(value.toLocaleString(lang, {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' + value.toLocaleString(lang, {timeStyle: 'short'}));
|
||||
}
|
||||
}
|
||||
this._ShowHideInfoItem(this.lblDate, !!value);
|
||||
} else if (pdfProps)
|
||||
this.updatePdfInfo(pdfProps);
|
||||
|
@ -1544,8 +1551,16 @@ define([
|
|||
if (props) {
|
||||
var visible = false;
|
||||
value = props.asc_getModified();
|
||||
if (value)
|
||||
this.lblModifyDate.text(value.toLocaleString(this.mode.lang, {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' + value.toLocaleString(this.mode.lang, {timeStyle: 'short'}));
|
||||
|
||||
if (value) {
|
||||
var lang = (this.mode.lang || 'en').replace('_', '-').toLowerCase();
|
||||
try {
|
||||
this.lblModifyDate.text(value.toLocaleString(lang, {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' + value.toLocaleString(lang, {timeStyle: 'short'}));
|
||||
} catch (e) {
|
||||
lang = 'en';
|
||||
this.lblModifyDate.text(value.toLocaleString(lang, {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' + value.toLocaleString(lang, {timeStyle: 'short'}));
|
||||
}
|
||||
}
|
||||
visible = this._ShowHideInfoItem(this.lblModifyDate, !!value) || visible;
|
||||
value = props.asc_getLastModifiedBy();
|
||||
if (value)
|
||||
|
@ -1586,7 +1601,13 @@ define([
|
|||
value = props.CreationDate;
|
||||
if (value) {
|
||||
value = new Date(value);
|
||||
this.lblDate.text(value.toLocaleString(this.mode.lang, {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' + value.toLocaleString(this.mode.lang, {timeStyle: 'short'}));
|
||||
var lang = (this.mode.lang || 'en').replace('_', '-').toLowerCase();
|
||||
try {
|
||||
this.lblDate.text(value.toLocaleString(lang, {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' + value.toLocaleString(lang, {timeStyle: 'short'}));
|
||||
} catch (e) {
|
||||
lang = 'en';
|
||||
this.lblDate.text(value.toLocaleString(lang, {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' + value.toLocaleString(lang, {timeStyle: 'short'}));
|
||||
}
|
||||
}
|
||||
this._ShowHideInfoItem(this.lblDate, !!value);
|
||||
|
||||
|
@ -1594,7 +1615,13 @@ define([
|
|||
value = props.ModDate;
|
||||
if (value) {
|
||||
value = new Date(value);
|
||||
this.lblModifyDate.text(value.toLocaleString(this.mode.lang, {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' + value.toLocaleString(this.mode.lang, {timeStyle: 'short'}));
|
||||
var lang = (this.mode.lang || 'en').replace('_', '-').toLowerCase();
|
||||
try {
|
||||
this.lblModifyDate.text(value.toLocaleString(lang, {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' + value.toLocaleString(lang, {timeStyle: 'short'}));
|
||||
} catch (e) {
|
||||
lang = 'en';
|
||||
this.lblModifyDate.text(value.toLocaleString(lang, {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' + value.toLocaleString(lang, {timeStyle: 'short'}));
|
||||
}
|
||||
}
|
||||
visible = this._ShowHideInfoItem(this.lblModifyDate, !!value) || visible;
|
||||
visible = this._ShowHideInfoItem(this.lblModifyBy, false) || visible;
|
||||
|
|
|
@ -1215,8 +1215,15 @@ define([
|
|||
this.coreProps = (this.api) ? this.api.asc_getCoreProps() : null;
|
||||
if (this.coreProps) {
|
||||
var value = this.coreProps.asc_getCreated();
|
||||
if (value)
|
||||
this.lblDate.text(value.toLocaleString(this.mode.lang, {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' + value.toLocaleString(this.mode.lang, {timeStyle: 'short'}));
|
||||
if (value) {
|
||||
var lang = (this.mode.lang || 'en').replace('_', '-').toLowerCase();
|
||||
try {
|
||||
this.lblDate.text(value.toLocaleString(lang, {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' + value.toLocaleString(lang, {timeStyle: 'short'}));
|
||||
} catch (e) {
|
||||
lang = 'en';
|
||||
this.lblDate.text(value.toLocaleString(lang, {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' + value.toLocaleString(lang, {timeStyle: 'short'}));
|
||||
}
|
||||
}
|
||||
this._ShowHideInfoItem(this.lblDate, !!value);
|
||||
}
|
||||
},
|
||||
|
@ -1241,8 +1248,15 @@ define([
|
|||
if (props) {
|
||||
var visible = false;
|
||||
value = props.asc_getModified();
|
||||
if (value)
|
||||
this.lblModifyDate.text(value.toLocaleString(this.mode.lang, {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' + value.toLocaleString(this.mode.lang, {timeStyle: 'short'}));
|
||||
if (value) {
|
||||
var lang = (this.mode.lang || 'en').replace('_', '-').toLowerCase();
|
||||
try {
|
||||
this.lblModifyDate.text(value.toLocaleString(lang, {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' + value.toLocaleString(lang, {timeStyle: 'short'}));
|
||||
} catch (e) {
|
||||
lang = 'en';
|
||||
this.lblModifyDate.text(value.toLocaleString(lang, {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' + value.toLocaleString(lang, {timeStyle: 'short'}));
|
||||
}
|
||||
}
|
||||
visible = this._ShowHideInfoItem(this.lblModifyDate, !!value) || visible;
|
||||
value = props.asc_getLastModifiedBy();
|
||||
if (value)
|
||||
|
|
|
@ -1945,12 +1945,19 @@ define([
|
|||
case Asc.c_oAscError.ID.FillAllRowsWarning:
|
||||
var fill = errData[0],
|
||||
have = errData[1],
|
||||
fillWithSeparator = fill.toLocaleString(this.appOptions.lang);
|
||||
lang = (this.appOptions.lang || 'en').replace('_', '-').toLowerCase(),
|
||||
fillWithSeparator;
|
||||
try {
|
||||
fillWithSeparator = fill.toLocaleString(lang);
|
||||
} catch (e) {
|
||||
lang = 'en';
|
||||
fillWithSeparator = fill.toLocaleString(lang);
|
||||
}
|
||||
if (this.appOptions.isDesktopApp && this.appOptions.isOffline) {
|
||||
config.msg = fill > have ? Common.Utils.String.format(this.textFormulaFilledAllRowsWithEmpty, fillWithSeparator) : Common.Utils.String.format(this.textFormulaFilledAllRows, fillWithSeparator);
|
||||
config.buttons = [{caption: this.textFillOtherRows, primary: true, value: 'fillOther'}, 'close'];
|
||||
} else {
|
||||
config.msg = fill >= have ? Common.Utils.String.format(this.textFormulaFilledFirstRowsOtherIsEmpty, fillWithSeparator) : Common.Utils.String.format(this.textFormulaFilledFirstRowsOtherHaveData, fillWithSeparator, (have - fill).toLocaleString(this.appOptions.lang));
|
||||
config.msg = fill >= have ? Common.Utils.String.format(this.textFormulaFilledFirstRowsOtherIsEmpty, fillWithSeparator) : Common.Utils.String.format(this.textFormulaFilledFirstRowsOtherHaveData, fillWithSeparator, (have - fill).toLocaleString(lang));
|
||||
config.buttons = ['ok'];
|
||||
}
|
||||
config.maxwidth = 400;
|
||||
|
|
|
@ -1590,8 +1590,15 @@ SSE.Views.FileMenuPanels.RecentFiles = Common.UI.BaseView.extend({
|
|||
this.coreProps = (this.api) ? this.api.asc_getCoreProps() : null;
|
||||
if (this.coreProps) {
|
||||
var value = this.coreProps.asc_getCreated();
|
||||
if (value)
|
||||
this.lblDate.text(value.toLocaleString(this.mode.lang, {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' + value.toLocaleString(this.mode.lang, {timeStyle: 'short'}));
|
||||
if (value) {
|
||||
var lang = (this.mode.lang || 'en').replace('_', '-').toLowerCase();
|
||||
try {
|
||||
this.lblDate.text(value.toLocaleString(lang, {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' + value.toLocaleString(lang, {timeStyle: 'short'}));
|
||||
} catch (e) {
|
||||
lang = 'en';
|
||||
this.lblDate.text(value.toLocaleString(lang, {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' + value.toLocaleString(lang, {timeStyle: 'short'}));
|
||||
}
|
||||
}
|
||||
this._ShowHideInfoItem(this.lblDate, !!value);
|
||||
}
|
||||
},
|
||||
|
@ -1616,8 +1623,15 @@ SSE.Views.FileMenuPanels.RecentFiles = Common.UI.BaseView.extend({
|
|||
if (props) {
|
||||
var visible = false;
|
||||
value = props.asc_getModified();
|
||||
if (value)
|
||||
this.lblModifyDate.text(value.toLocaleString(this.mode.lang, {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' + value.toLocaleString(this.mode.lang, {timeStyle: 'short'}));
|
||||
if (value) {
|
||||
var lang = (this.mode.lang || 'en').replace('_', '-').toLowerCase();
|
||||
try {
|
||||
this.lblModifyDate.text(value.toLocaleString(lang, {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' + value.toLocaleString(lang, {timeStyle: 'short'}));
|
||||
} catch (e) {
|
||||
lang = 'en';
|
||||
this.lblModifyDate.text(value.toLocaleString(lang, {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' + value.toLocaleString(lang, {timeStyle: 'short'}));
|
||||
}
|
||||
}
|
||||
visible = this._ShowHideInfoItem(this.lblModifyDate, !!value) || visible;
|
||||
value = props.asc_getLastModifiedBy();
|
||||
if (value)
|
||||
|
|
Loading…
Reference in a new issue