fitzroy 1.7.0 → 1.7.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/dist/cli.js CHANGED
@@ -135,7 +135,7 @@ function parseFootyWireDate(dateStr, defaultYear) {
135
135
  const minutes = Number.parseInt(minStr, 10);
136
136
  if (ampm.toLowerCase() === "pm" && aestHours < 12) aestHours += 12;
137
137
  if (ampm.toLowerCase() === "am" && aestHours === 12) aestHours = 0;
138
- const date = new Date(Date.UTC(defaultYear, monthIndex, day, aestHours - 10, minutes));
138
+ const date = melbourneLocalToUtc(defaultYear, monthIndex, day, aestHours, minutes);
139
139
  if (Number.isNaN(date.getTime())) return null;
140
140
  return date;
141
141
  }
@@ -168,6 +168,20 @@ function resolveDefaultSeason(competition = "AFLM") {
168
168
  const year = (/* @__PURE__ */ new Date()).getFullYear();
169
169
  return competition === "AFLW" ? year - 1 : year;
170
170
  }
171
+ function melbourneLocalToUtc(year, monthIndex, day, hours, minutes) {
172
+ const aestGuess = new Date(Date.UTC(year, monthIndex, day, hours - 10, minutes));
173
+ const parts = new Intl.DateTimeFormat("en-AU", {
174
+ timeZone: "Australia/Melbourne",
175
+ day: "2-digit",
176
+ hour: "2-digit",
177
+ hour12: false
178
+ }).formatToParts(aestGuess);
179
+ const getNum = (type) => Number(parts.find((p) => p.type === type)?.value);
180
+ if (getNum("day") === day && getNum("hour") === hours % 24) {
181
+ return aestGuess;
182
+ }
183
+ return new Date(Date.UTC(year, monthIndex, day, hours - 11, minutes));
184
+ }
171
185
  function buildUtcDate(year, monthStr, day) {
172
186
  const monthIndex = MONTH_ABBREV_TO_INDEX.get(monthStr.toLowerCase());
173
187
  if (monthIndex === void 0) {
@@ -5786,7 +5800,7 @@ resolveAliases();
5786
5800
  var main = defineCommand11({
5787
5801
  meta: {
5788
5802
  name: "fitzroy",
5789
- version: "1.7.0",
5803
+ version: "1.7.1",
5790
5804
  description: "TypeScript port of the fitzRoy R package \u2014 fetch AFL data from the command line"
5791
5805
  },
5792
5806
  subCommands: {
package/dist/index.js CHANGED
@@ -82,7 +82,7 @@ function parseFootyWireDate(dateStr, defaultYear) {
82
82
  const minutes = Number.parseInt(minStr, 10);
83
83
  if (ampm.toLowerCase() === "pm" && aestHours < 12) aestHours += 12;
84
84
  if (ampm.toLowerCase() === "am" && aestHours === 12) aestHours = 0;
85
- const date = new Date(Date.UTC(defaultYear, monthIndex, day, aestHours - 10, minutes));
85
+ const date = melbourneLocalToUtc(defaultYear, monthIndex, day, aestHours, minutes);
86
86
  if (Number.isNaN(date.getTime())) return null;
87
87
  return date;
88
88
  }
@@ -154,6 +154,20 @@ var MONTH_ABBREV_TO_INDEX = /* @__PURE__ */ new Map([
154
154
  ["november", 10],
155
155
  ["december", 11]
156
156
  ]);
157
+ function melbourneLocalToUtc(year, monthIndex, day, hours, minutes) {
158
+ const aestGuess = new Date(Date.UTC(year, monthIndex, day, hours - 10, minutes));
159
+ const parts = new Intl.DateTimeFormat("en-AU", {
160
+ timeZone: "Australia/Melbourne",
161
+ day: "2-digit",
162
+ hour: "2-digit",
163
+ hour12: false
164
+ }).formatToParts(aestGuess);
165
+ const getNum = (type) => Number(parts.find((p) => p.type === type)?.value);
166
+ if (getNum("day") === day && getNum("hour") === hours % 24) {
167
+ return aestGuess;
168
+ }
169
+ return new Date(Date.UTC(year, monthIndex, day, hours - 11, minutes));
170
+ }
157
171
  function buildUtcDate(year, monthStr, day) {
158
172
  const monthIndex = MONTH_ABBREV_TO_INDEX.get(monthStr.toLowerCase());
159
173
  if (monthIndex === void 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fitzroy",
3
- "version": "1.7.0",
3
+ "version": "1.7.1",
4
4
  "description": "TypeScript port of the fitzRoy R package — programmatic access to AFL data including match results, player stats, fixtures, ladders, and more",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",