client/js/foundation/locale_settings/locale_settings.js in rsence-pre-3.0.0.8 vs client/js/foundation/locale_settings/locale_settings.js in rsence-pre-3.0.0.9

- old
+ new

@@ -1,11 +1,18 @@ var -HLocale = { +HLocale = (UtilMethods.extend({ + setData: function(_locale){ + this.updateObject(_locale,this); + }, components: { - + }, + general: { + decimalSeparator: '.', + thousandsSeparator: '' + }, compUnits: { strings: { bit: ' b', 'byte': ' B', kilobyte: ' kB', @@ -85,17 +92,22 @@ weekLong: 'Week', weekShort: 'WK', dateDelimitter: '.', timeDelimitter: ':', timeMsDelimitter: '.', - rangeDelimitter: ' ... ' + rangeDelimitter: ' ... ', + dateFormat: 'YYYY-MM-DD', + timeFormat: 'HH:mm:ss', + dateTimeFormat: 'YYYY-MM-DD HH:mm:ss' }, settings: { zeroPadTime: true, AMPM: false }, defaultOptions: { + useUTC: true, + tzMinutes: 0, longWeekDay: false, shortWeekDay: false, shortYear: false, fullYear: true, seconds: false, @@ -108,16 +120,15 @@ _options = {}, _key; for( _key in _default ){ _options[_key] = _default[_key]; } - if( !_custom ){ - _custom = {}; + if( _custom ){ + for( _key in _custom ){ + _options[_key] = _custom[_key]; + } } - for( _key in _custom ){ - _options[_key] = _custom[_key]; - } return _options; }, zeroPadTime: function( _num ){ if( HLocale.dateTime.settings.zeroPadTime && _num < 10 ){ return '0'+_num; @@ -127,64 +138,64 @@ formatShortWeekDay: function( _dateTimeEpoch ){ var _this = HLocale.dateTime, _date = new Date( _dateTimeEpoch * 1000 ), _strings = _this.strings, - _wday = _date.getUTCDay(); + _wday = _this.options().useUTC?_date.getUTCDay():_date.getDay(); return _strings.weekDaysShort[ _wday ]; }, formatLongWeekDay: function( _dateTimeEpoch ){ var _this = HLocale.dateTime, _date = new Date( _dateTimeEpoch * 1000 ), _strings = _this.strings, - _wday = _date.getUTCDay(); + _wday = _this.options().useUTC?_date.getUTCDay():_date.getDay(); return _strings.weekDaysLong[ _wday ]; }, formatDate: function( _dateTimeEpoch, _options ){ + _options = this.options( _options ); var _this = HLocale.dateTime, _date = new Date( _dateTimeEpoch * 1000 ), _strings = _this.strings, - _wday = _date.getUTCDay(), - _dateString = _date.getUTCDate() + _strings.dateDelimitter + (_date.getUTCMonth() + 1) + _strings.dateDelimitter; - - _options = _this.options( _options ); - + _wday = _options.useUTC?_date.getUTCDay():_date.getDay(), + _dateString = _options.useUTC?(_date.getUTCDate() + _strings.dateDelimitter + (_date.getUTCMonth() + 1) + _strings.dateDelimitter): + (_date.getDate() + _strings.dateDelimitter + (_date.getMonth() + 1) + _strings.dateDelimitter); + if( _options.fullYear ){ - _dateString += _date.getUTCFullYear(); + _dateString += _options.useUTC?_date.getUTCFullYear():_date.getFullYear(); } else if( _options.shortYear ){ - _dateString += date.getUTCYear(); + _dateString += _options.useUTC?_date.getUTCYear():_date.getYear(); } - + if( _options.longWeekDay ){ return _strings.weekDaysLong[_wday] + ' ' + _dateString; } else if( _options.shortWeekDay ){ return _strings.weekDaysShort[_wday] + ' ' + _dateString; } return _dateString; }, formatTime: function( _dateTimeEpoch, _options ){ + _options = this.options( _options ); var _this = HLocale.dateTime, _date = new Date( _dateTimeEpoch * 1000 ), _strings = _this.strings, - _timeString = _this.zeroPadTime( _date.getUTCHours() ) + _strings.timeDelimitter + _this.zeroPadTime( _date.getUTCMinutes() ); - - _options = _this.options( _options ); - + _timeString = _options.useUTC?(_this.zeroPadTime( _date.getUTCHours() ) + _strings.timeDelimitter + _this.zeroPadTime( _date.getUTCMinutes() )): + (_this.zeroPadTime( _date.getHours() ) + _strings.timeDelimitter + _this.zeroPadTime( _date.getMinutes() )); + if( _options.seconds ){ - _timeString += _strings.timeDelimitter + _this.zeroPadTime( _date.getUTCSeconds() ); + _timeString += _strings.timeDelimitter + _this.zeroPadTime( _options.useUTC?_date.getUTCSeconds():_date.getSeconds() ); if( _options.milliSeconds ){ - _timeString += _strings.timeMsDelimitter + _date.getUTCMilliseconds(); + _timeString += _strings.timeMsDelimitter + _options.useUTC?_date.getUTCMilliseconds():_date.getMilliseconds; } } return _timeString; }, formatDateTime: function( _dateTimeEpoch, _options ){ var _this = HLocale.dateTime; return _this.formatDate( _dateTimeEpoch, _options ) + ' ' + _this.formatTime( _dateTimeEpoch, _options ); } } -}; +})).nu();