MCPcopy Create free account
hub / github.com/ampproject/amphtml / getVariablesInUTC

Function getVariablesInUTC

extensions/amp-date-display/1.0/component.js:217–259  ·  view source on GitHub ↗

* @param {!Date} date * @param {string} locale * @param {?{[key: string]: *}} localeOptions * @return {!VariablesV2Def}

(
  date,
  locale,
  localeOptions = DEFAULT_DATETIME_OPTIONS
)

Source from the content-addressed store, hash-verified

215 * @return {!VariablesV2Def}
216 */
217function getVariablesInUTC(
218 date,
219 locale,
220 localeOptions = DEFAULT_DATETIME_OPTIONS
221) {
222 const localeOptionsInUTC = {
223 ...localeOptions,
224 timeZone: 'UTC',
225 };
226 return {
227 'year': date.getUTCFullYear(),
228 'month': date.getUTCMonth() + 1,
229 'monthName': date.toLocaleDateString(locale, {
230 month: 'long',
231 timeZone: 'UTC',
232 }),
233 'monthNameShort': date.toLocaleDateString(locale, {
234 month: 'short',
235 timeZone: 'UTC',
236 }),
237 'day': date.getUTCDate(),
238 'dayName': date.toLocaleDateString(locale, {
239 weekday: 'long',
240 timeZone: 'UTC',
241 }),
242 'dayNameShort': date.toLocaleDateString(locale, {
243 weekday: 'short',
244 timeZone: 'UTC',
245 }),
246 'hour': date.getUTCHours(),
247 'minute': date.getUTCMinutes(),
248 'second': date.getUTCSeconds(),
249 'iso': date.toISOString(),
250 'localeString': getLocaleString_(date, locale, localeOptionsInUTC),
251 'timeZoneName': getTimeZoneName(date, locale, localeOptionsInUTC),
252 'timeZoneNameShort': getTimeZoneName(
253 date,
254 locale,
255 localeOptionsInUTC,
256 'short'
257 ),
258 };
259}

Callers 1

BentoDateDisplayFunction · 0.85

Calls 1

getTimeZoneNameFunction · 0.90

Tested by

no test coverage detected