MCPcopy Index your code
hub / github.com/angular/angular / padNumber

Function padNumber

packages/common/src/i18n/format_date.ts:284–308  ·  view source on GitHub ↗
(
  num: number,
  digits: number,
  minusSign = '-',
  trim?: boolean,
  negWrap?: boolean,
)

Source from the content-addressed store, hash-verified

282}
283
284function padNumber(
285 num: number,
286 digits: number,
287 minusSign = '-',
288 trim?: boolean,
289 negWrap?: boolean,
290): string {
291 let neg = '';
292 if (num < 0 || (negWrap && num <= 0)) {
293 if (negWrap) {
294 num = -num + 1;
295 } else {
296 num = -num;
297 neg = minusSign;
298 }
299 }
300 let strNum = String(num);
301 while (strNum.length < digits) {
302 strNum = '0' + strNum;
303 }
304 if (trim) {
305 strNum = strNum.slice(strNum.length - digits);
306 }
307 return neg + strNum;
308}
309
310function formatFractionalSeconds(milliseconds: number, digits: number): string {
311 const strMs = padNumber(milliseconds, 3);

Callers 5

formatFractionalSecondsFunction · 0.85
dateGetterFunction · 0.85
timeZoneGetterFunction · 0.85
weekGetterFunction · 0.85
weekNumberingYearGetterFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…