@d3lm/pr-stats 0.1.0 → 0.1.2
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/dist/index.mjs +25 -7
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1492,7 +1492,7 @@ var OPTIONS = [
|
|
|
1492
1492
|
name: "charts",
|
|
1493
1493
|
short: "c",
|
|
1494
1494
|
type: "string",
|
|
1495
|
-
default: "histogram,strip
|
|
1495
|
+
default: "histogram,strip",
|
|
1496
1496
|
placeholder: "<list>",
|
|
1497
1497
|
help: "Choose which size charts to print as a comma-separated list. Accepts `histogram` (size distribution bars), `strip` (a quantile strip per metric), and `spark` (a size line chart over time). All three print by default. Pass `none` to print no charts."
|
|
1498
1498
|
},
|
|
@@ -1508,7 +1508,7 @@ var OPTIONS = [
|
|
|
1508
1508
|
type: "string",
|
|
1509
1509
|
default: "0-24",
|
|
1510
1510
|
placeholder: "<v>",
|
|
1511
|
-
help: "Count only these working hours instead of full weekdays. Accepts
|
|
1511
|
+
help: "Count only these working hours instead of full weekdays. Accepts 24-hour ranges like `9-17` or `8:30-16:30`, 12-hour ranges like `9am-6pm` or `8:30am-4:30pm`, or several comma-separated ranges like `9-18,19:30-20:30`. Without this flag, every hour Mon-Fri counts."
|
|
1512
1512
|
},
|
|
1513
1513
|
{
|
|
1514
1514
|
name: "wall-clock",
|
|
@@ -1681,15 +1681,33 @@ function parseCharts(value2) {
|
|
|
1681
1681
|
}
|
|
1682
1682
|
return charts;
|
|
1683
1683
|
}
|
|
1684
|
+
function toMinutesOfDay(hourText, minuteText, meridiem) {
|
|
1685
|
+
const minute = Number(minuteText ?? 0);
|
|
1686
|
+
if (minute > 59) {
|
|
1687
|
+
return null;
|
|
1688
|
+
}
|
|
1689
|
+
let hour = Number(hourText);
|
|
1690
|
+
if (meridiem !== void 0) {
|
|
1691
|
+
if (hour < 1 || hour > 12) {
|
|
1692
|
+
return null;
|
|
1693
|
+
}
|
|
1694
|
+
hour %= 12;
|
|
1695
|
+
if (meridiem.toLowerCase() === "pm") {
|
|
1696
|
+
hour += 12;
|
|
1697
|
+
}
|
|
1698
|
+
}
|
|
1699
|
+
return hour * 60 + minute;
|
|
1700
|
+
}
|
|
1684
1701
|
function parseWorkHours(value2) {
|
|
1685
1702
|
const windows = value2.split(",").map((range) => {
|
|
1686
|
-
const match = /^(\d{1,2})(?::(\d{2}))?-(\d{1,2})(?::(\d{2}))
|
|
1703
|
+
const match = /^(\d{1,2})(?::(\d{2}))?(am|pm)?-(\d{1,2})(?::(\d{2}))?(am|pm)?$/i.exec(range.trim());
|
|
1687
1704
|
if (!match) {
|
|
1688
|
-
fail(`invalid --work-hours range "${range}", use ranges like 9-17, 8:30-16:30, or 9-18,19:30-20:30`);
|
|
1705
|
+
fail(`invalid --work-hours range "${range}", use ranges like 9-17, 9am-6pm, 8:30-16:30, or 9-18,19:30-20:30`);
|
|
1689
1706
|
}
|
|
1690
|
-
const startMin =
|
|
1691
|
-
const
|
|
1692
|
-
|
|
1707
|
+
const startMin = toMinutesOfDay(match[1], match[2], match[3]);
|
|
1708
|
+
const end = toMinutesOfDay(match[4], match[5], match[6]);
|
|
1709
|
+
const endMin = end === 0 ? 24 * 60 : end;
|
|
1710
|
+
if (startMin === null || endMin === null || endMin <= startMin || endMin > 24 * 60) {
|
|
1693
1711
|
fail(`invalid --work-hours range "${range}"`);
|
|
1694
1712
|
}
|
|
1695
1713
|
return { startMin, endMin };
|