Skip to content

Commit f172538

Browse files
committed
Improve JSDoc documentation
1 parent 8a024fe commit f172538

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/shared/dates.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export function getBeginOfDecadeYear(date) {
8181
* Returns the beginning of a given week.
8282
*
8383
* @param {Date} date Date.
84-
* @param {string} calendarType Calendar type.
84+
* @param {string} [calendarType="ISO 8601"] Calendar type.
8585
*/
8686
export function getBeginOfWeek(date, calendarType = CALENDAR_TYPES.ISO_8601) {
8787
const year = getYear(date);
@@ -96,7 +96,7 @@ export function getBeginOfWeek(date, calendarType = CALENDAR_TYPES.ISO_8601) {
9696
* In US calendar week 1 is the one with January 1.
9797
*
9898
* @param {Date} date Date.
99-
* @param {string} calendarType Calendar type.
99+
* @param {string} [calendarType="ISO 8601"] Calendar type.
100100
*/
101101
export function getWeekNumber(date, calendarType = CALENDAR_TYPES.ISO_8601) {
102102
const calendarTypeForWeekNumber =
@@ -289,12 +289,19 @@ function toYearLabel(locale, formatYear = defaultFormatYear, dates) {
289289
return dates.map((date) => formatYear(locale, date)).join(' – ');
290290
}
291291

292+
/**
293+
* @callback FormatYear
294+
* @param {string} locale Locale.
295+
* @param {Date} date Date.
296+
* @returns {string} Formatted year.
297+
*/
298+
292299
/**
293300
* Returns a string labelling a century of a given date.
294301
* For example, for 2017 it will return 2001-2100.
295302
*
296303
* @param {string} locale Locale.
297-
* @param {function} formatYear Function to format a year.
304+
* @param {FormatYear} formatYear Function to format a year.
298305
* @param {Date|string|number} date Date or a year as a string or as a number.
299306
*/
300307
export function getCenturyLabel(locale, formatYear, date) {
@@ -306,7 +313,7 @@ export function getCenturyLabel(locale, formatYear, date) {
306313
* For example, for 2017 it will return 2011-2020.
307314
*
308315
* @param {string} locale Locale.
309-
* @param {function} formatYear Function to format a year.
316+
* @param {FormatYear} formatYear Function to format a year.
310317
* @param {Date|string|number} date Date or a year as a string or as a number.
311318
*/
312319
export function getDecadeLabel(locale, formatYear, date) {
@@ -326,7 +333,7 @@ export function isCurrentDayOfWeek(date) {
326333
* Returns a boolean determining whether a given date is a weekend day.
327334
*
328335
* @param {Date} date Date.
329-
* @param {string} calendarType Calendar type.
336+
* @param {string} [calendarType="ISO 8601"] Calendar type.
330337
*/
331338
export function isWeekend(date, calendarType = CALENDAR_TYPES.ISO_8601) {
332339
const weekday = date.getDay();

0 commit comments

Comments
 (0)