@code-pushup/utils 0.9.0 → 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -586,6 +586,18 @@ function formatDuration(duration) {
586
586
  }
587
587
  return `${(duration / 1e3).toFixed(2)} s`;
588
588
  }
589
+ function formatDate(date) {
590
+ const locale = "en-US";
591
+ return date.toLocaleString(locale, {
592
+ weekday: "short",
593
+ month: "short",
594
+ day: "numeric",
595
+ year: "numeric",
596
+ hour: "numeric",
597
+ minute: "2-digit",
598
+ timeZoneName: "short"
599
+ }).replace(/\u202F/g, " ");
600
+ }
589
601
  function truncateText(text, maxChars) {
590
602
  if (text.length <= maxChars) {
591
603
  return text;
@@ -1264,7 +1276,7 @@ function reportToDetailsSection(audit) {
1264
1276
  return details(detailsTitle, detailsTable);
1265
1277
  }
1266
1278
  function reportToAboutSection(report, commitData) {
1267
- const date = (/* @__PURE__ */ new Date()).toString();
1279
+ const date = formatDate(/* @__PURE__ */ new Date());
1268
1280
  const { duration, version, plugins, categories } = report;
1269
1281
  const commitInfo = commitData ? `${commitData.message} (${commitData.hash.slice(0, 7)})` : "N/A";
1270
1282
  const reportMetaTable = [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@code-pushup/utils",
3
- "version": "0.9.0",
3
+ "version": "0.10.1",
4
4
  "dependencies": {
5
5
  "@code-pushup/models": "*",
6
6
  "bundle-require": "^4.0.1",
@@ -3,6 +3,7 @@ export declare function pluralize(text: string): string;
3
3
  export declare function formatBytes(bytes: number, decimals?: number): string;
4
4
  export declare function pluralizeToken(token: string, times?: number): string;
5
5
  export declare function formatDuration(duration: number): string;
6
+ export declare function formatDate(date: Date): string;
6
7
  export declare function truncateText(text: string, maxChars: number): string;
7
8
  export declare function truncateTitle(text: string): string;
8
9
  export declare function truncateDescription(text: string): string;