@tailgatefantasysports/seasonservice 0.4.21 → 0.5.0

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.
Files changed (2) hide show
  1. package/SeasonService.js +23 -0
  2. package/package.json +1 -1
package/SeasonService.js CHANGED
@@ -93,6 +93,29 @@ module.exports = class SeasonService {
93
93
  return full;
94
94
  }
95
95
 
96
+ /**
97
+ * Returns the regular season frame for a given season year, or null if not configured.
98
+ * @param {string|number} seasonYear
99
+ * @returns {{ season: string, type: string, start: Date, end: Date }|null}
100
+ */
101
+ getRegularSeason(seasonYear) {
102
+ const frames = this.timeframes[seasonYear];
103
+ if (!frames) return null;
104
+ const types = require('./types');
105
+ const frame = frames[types.regular] || frames['regular'];
106
+ if (!frame) return null;
107
+ return { season: String(seasonYear), type: types.regular, ...frame };
108
+ }
109
+
110
+ /**
111
+ * Returns the total number of weeks in the regular season for a given season object.
112
+ * @param {{ season: string, start: Date, end: Date }} season - regular season frame
113
+ * @returns {number}
114
+ */
115
+ getTotalWeeks(season) {
116
+ return Math.round((season.end - season.start) / this._weekInMs);
117
+ }
118
+
96
119
  /**
97
120
  * Walks to a nearby season from date in direction
98
121
  * @param {number} direction - direction to get season (1 for next, -1 for previous)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tailgatefantasysports/seasonservice",
3
- "version": "0.4.21",
3
+ "version": "0.5.0",
4
4
  "description": "Generic Season Service",
5
5
  "main": "index.js",
6
6
  "scripts": {