MCPcopy Index your code
hub / github.com/microsoft/SandDance / formatYear

Function formatYear

docs/app/js/sanddance-app.js:109241–109243  ·  view source on GitHub ↗
(year)

Source from the content-addressed store, hash-verified

109239 return length < width ? new Array(width - length + 1).join(0) + s : s;
109240}
109241function formatYear(year) {
109242 return year < 0 ? "-" + pad(-year, 6) : year > 9999 ? "+" + pad(year, 6) : pad(year, 4);
109243}
109244function formatDate(date) {
109245 var hours = date.getUTCHours(), minutes = date.getUTCMinutes(), seconds = date.getUTCSeconds(), milliseconds = date.getUTCMilliseconds();
109246 return isNaN(date) ? "Invalid Date" : formatYear(date.getUTCFullYear(), 4) + "-" + pad(date.getUTCMonth() + 1, 2) + "-" + pad(date.getUTCDate(), 2) + (milliseconds ? "T" + pad(hours, 2) + ":" + pad(minutes, 2) + ":" + pad(seconds, 2) + "." + pad(milliseconds, 3) + "Z" : seconds ? "T" + pad(hours, 2) + ":" + pad(minutes, 2) + ":" + pad(seconds, 2) + "Z" : minutes || hours ? "T" + pad(hours, 2) + ":" + pad(minutes, 2) + "Z" : "");

Callers 1

formatDateFunction · 0.70

Calls 1

padFunction · 0.70

Tested by

no test coverage detected