MCPcopy
hub / github.com/node-cron/node-cron / getPartsFormatter

Function getPartsFormatter

src/time/localized-time.ts:112–135  ·  view source on GitHub ↗
(timezone?: string)

Source from the content-addressed store, hash-verified

110const offsetFormatterCache = new Map<string, Intl.DateTimeFormat>();
111
112function getPartsFormatter(timezone?: string): Intl.DateTimeFormat {
113 const key = timezone ?? '';
114 let formatter = partsFormatterCache.get(key);
115 if (!formatter) {
116 const dftOptions: Intl.DateTimeFormatOptions = {
117 year: 'numeric',
118 month: '2-digit',
119 day: '2-digit',
120 hour: '2-digit',
121 minute: '2-digit',
122 second: '2-digit',
123 weekday: 'short',
124 hour12: false
125 }
126
127 if(timezone){
128 dftOptions.timeZone = timezone;
129 }
130
131 formatter = new Intl.DateTimeFormat('en-US', dftOptions);
132 partsFormatterCache.set(key, formatter);
133 }
134 return formatter;
135}
136
137function getOffsetFormatter(timezone?: string): Intl.DateTimeFormat {
138 const key = timezone ?? '';

Callers 1

buildDatePartsFunction · 0.85

Calls 1

getMethod · 0.80

Tested by

no test coverage detected