Skip to content

Commit

Permalink
Merge pull request #247 from enyojs/ENYO-3180-ryanjduffy
Browse files Browse the repository at this point in the history
Fixes ENYO-3180 remove locale property from DatePicker and TimePicker
  • Loading branch information
webOS101 committed Mar 11, 2016
2 parents 060ee3d + 22770b1 commit cfa64b8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 36 deletions.
27 changes: 9 additions & 18 deletions src/i18n/DatePicker.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
require('onyx');
require('enyo-ilib');

/**
* Contains the declaration for the {@link module:onyx/i18n/DatePicker~DatePicker} kind.
* @module onyx/i18n/DatePicker
*/

var
kind = require('enyo/kind');
kind = require('enyo/kind'),
Signals = require('enyo/Signals');

var
ilib = require('enyo-ilib'),
DateFmt = require('enyo-ilib/DateFmt');

var
Expand Down Expand Up @@ -42,28 +43,19 @@ module.exports = kind(
kind: DatePicker,

/**
* @lends module:onyx/i18n/DatePicker~DatePicker.prototype
* @private
*/
published: {
/**
* Current locale used for formatting. If `null`, the value will be determined by
* iLib.
*
* @type {String|null}
* @default null
* @public
*/
locale: null
create: function () {
DatePicker.prototype.create.apply(this, arguments);
this.createComponent({kind: Signals, onlocalechange: 'localeChanged'});
},

/**
* @private
*/
create: function () {
this.locale = this.locale || ilib.getLocale();
this._tf = new DateFmt({locale: this.locale, timezone: 'local'});
DatePicker.prototype.create.apply(this, arguments);
initDefaults: function () {
this._tf = new DateFmt({timezone: 'local'});
DatePicker.prototype.initDefaults.apply(this, arguments);
},

/**
Expand All @@ -86,7 +78,6 @@ module.exports = kind(
* @private
*/
localeChanged: function () {
this._tf = new DateFmt({locale: this.locale, timezone: 'local'});
this.refresh();
}

Expand Down
33 changes: 15 additions & 18 deletions src/i18n/TimePicker.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
require('onyx');
require('enyo-ilib');

/**
* Contains the declaration for the {@link module:onyx/i18n/TimePicker~TimePicker} kind.
* @module onyx/i18n/TimePicker
*/

var
kind = require('enyo/kind');
kind = require('enyo/kind'),
Signals = require('enyo/Signals');

var
ilib = require('enyo-ilib'),
dateFactory = require('enyo-ilib/DateFactory'),
DateFmt = require('enyo-ilib/DateFmt');

Expand Down Expand Up @@ -44,16 +45,6 @@ module.exports = kind(
* @private
*/
published: {
/**
* Current locale used for formatting. If `null`, the value will be determined by
* iLib.
*
* @type {String|null}
* @default null
* @public
*/
locale: null,

/**
* If `true`, 24-hour time is used. If `null` or when the locale is changed, this value is
* updated to reflect the locale's rules.
Expand All @@ -63,29 +54,35 @@ module.exports = kind(
* @public
*/
is24HrMode: null

},

/**
* @private
*/
create: function () {
this.locale = this.locale || ilib.getLocale();
this._tf = new DateFmt({locale:this.locale, timezone: 'local'});
TimePicker.prototype.create.apply(this, arguments);
this.createComponent({kind: Signals, onlocalechange: 'localeChanged'});
},

/**
* @private
*/
initDefaults: function () {
this._tf = new DateFmt({timezone: 'local'});
TimePicker.prototype.initDefaults.apply(this, arguments);
},

/**
* Sets meridiems and will set 24Hr mode based on locale if it was not specified
* @private
*/
setupMeridiems: function () {
var objAmPm = new DateFmt({locale: this.locale, type: 'time', template: 'a'}),
timeobj = dateFactory({locale: this.locale, hour: 1});
var objAmPm = new DateFmt({type: 'time', template: 'a'}),
timeobj = dateFactory({hour: 1});

this._strAm = objAmPm.format(timeobj);
// TODO: Does not support locales with more than two meridiems. See moonstone/TimePicker
timeobj.hour = 13;
timeobj.setHours(13);
this._strPm = objAmPm.format(timeobj);

if (this.is24HrMode == null) {
Expand Down

0 comments on commit cfa64b8

Please sign in to comment.