Skip to content
This repository has been archived by the owner on Aug 1, 2024. It is now read-only.

Commit

Permalink
Internal cleanup for handling minutes of dateLike input.
Browse files Browse the repository at this point in the history
RELNOTES: n/a

PiperOrigin-RevId: 458093706
Change-Id: I0bba1025954c492c14e760f87600fdb8c9273b99
  • Loading branch information
Closure Team authored and copybara-github committed Jun 29, 2022
1 parent c45b537 commit e687b3d
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions closure/goog/i18n/datetimeformat.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,18 @@ goog.i18n.DateTimeFormat.getHours_ = function(date) {
0;
};

/**
* @param {!goog.date.DateLike} date
* @return {number}
* @private
*/
goog.i18n.DateTimeFormat.getMinutes_ = function(date) {
'use strict';
return /** @type {?} */ (date).getMinutes ?
/** @type {?} */ (date).getMinutes() :
0;
};


/**
* Apply specified pattern to this formatter object.
Expand Down Expand Up @@ -897,7 +909,7 @@ goog.i18n.DateTimeFormat.prototype.formatAmPmNoonMidnight_ = function(
'use strict';
goog.i18n.DateTimeFormat.validateDateHasTime_(date);
const hours = goog.i18n.DateTimeFormat.getHours_(date);
const minutes = (date).getMinutes();
const minutes = goog.i18n.DateTimeFormat.getMinutes_(date);

/** {?goog.i18n.DayPeriods} */
const dayPeriods = goog.i18n.DayPeriods.getDayPeriods();
Expand Down Expand Up @@ -926,8 +938,9 @@ goog.i18n.DateTimeFormat.prototype.formatAmPmNoonMidnight_ = function(
goog.i18n.DateTimeFormat.prototype.formatFlexibleDayPeriods_ = function(
count, date) {
'use strict';
goog.i18n.DateTimeFormat.validateDateHasTime_(date);
const hours = goog.i18n.DateTimeFormat.getHours_(date);
const minutes = (date).getMinutes();
const minutes = goog.i18n.DateTimeFormat.getMinutes_(date);
// String in HH:MM format for comparing.
const fmtTime = hours.toString(10).padStart(2, '0') + ':' +
minutes.toString().padStart(2, '0');
Expand Down Expand Up @@ -1117,8 +1130,8 @@ goog.i18n.DateTimeFormat.prototype.formatDate_ = function(count, date) {
goog.i18n.DateTimeFormat.prototype.formatMinutes_ = function(count, date) {
'use strict';
goog.i18n.DateTimeFormat.validateDateHasTime_(date);
return this.localizeNumbers_(goog.string.padNumber(
/** @type {!goog.date.DateTime} */ (date).getMinutes(), count));
return this.localizeNumbers_(
goog.string.padNumber(goog.i18n.DateTimeFormat.getMinutes_(date), count));
};


Expand Down

0 comments on commit e687b3d

Please sign in to comment.