volleyballsimtypes 0.0.414 → 0.0.415

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.
@@ -4,15 +4,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const dayjs_1 = __importDefault(require("dayjs"));
7
+ const utc_1 = __importDefault(require("dayjs/plugin/utc"));
7
8
  const uuid_1 = require("uuid");
8
9
  const match_1 = require("./match");
9
10
  const utils_1 = require("../utils");
10
11
  const data_1 = require("../../data");
12
+ dayjs_1.default.extend(utc_1.default);
11
13
  // eslint-disable-next-line @typescript-eslint/no-extraneous-class
12
14
  class MatchGenerator {
13
15
  static generateMatches(teams, baseDate) {
14
16
  const t = new Set(teams.map(x => x.id));
15
- let date = (0, dayjs_1.default)(baseDate).startOf('hour');
17
+ // Anchor the first match to 00:00 UTC of the iteration's start day (Monday), so league rounds fall on the
18
+ // same wall-clock time everywhere regardless of the host timezone. startOf('day') in UTC avoids the
19
+ // local-timezone roll the old startOf('hour') was exposed to on a fractional-hour-offset host.
20
+ let date = dayjs_1.default.utc(baseDate).startOf('day');
16
21
  if (t.size !== teams.length) {
17
22
  throw new Error('DUPLICATE_TEAMS');
18
23
  }
@@ -1,13 +1,18 @@
1
1
  import dayjs from 'dayjs';
2
+ import utc from 'dayjs/plugin/utc';
2
3
  import { v4 as uuidv4 } from 'uuid';
3
4
  import { Match } from './match';
4
5
  import { shuffle } from '../utils';
5
6
  import { StatusEnum } from '../../data';
7
+ dayjs.extend(utc);
6
8
  // eslint-disable-next-line @typescript-eslint/no-extraneous-class
7
9
  export default class MatchGenerator {
8
10
  static generateMatches(teams, baseDate) {
9
11
  const t = new Set(teams.map(x => x.id));
10
- let date = dayjs(baseDate).startOf('hour');
12
+ // Anchor the first match to 00:00 UTC of the iteration's start day (Monday), so league rounds fall on the
13
+ // same wall-clock time everywhere regardless of the host timezone. startOf('day') in UTC avoids the
14
+ // local-timezone roll the old startOf('hour') was exposed to on a fractional-hour-offset host.
15
+ let date = dayjs.utc(baseDate).startOf('day');
11
16
  if (t.size !== teams.length) {
12
17
  throw new Error('DUPLICATE_TEAMS');
13
18
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "volleyballsimtypes",
3
- "version": "0.0.414",
3
+ "version": "0.0.415",
4
4
  "description": "vbsim types",
5
5
  "main": "./dist/cjs/src/index.js",
6
6
  "module": "./dist/esm/src/index.js",