-
-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b77b399
commit 0733da7
Showing
18 changed files
with
102 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- | ||
title: Utilities | ||
description: Discover 4 convenient date utilities provided with Vanilla Calendar Pro. These features allow you to format dates, convert them to desired formats, and determine week numbers. | ||
section: 2 | ||
--- | ||
|
||
# Utilities | ||
|
||
The calendar comes with its utilities, making it easy to work with date formatting. | ||
|
||
There are 4 utilities in total, and they are functions that can be used anywhere in your code, even without the calendar. | ||
|
||
1. **`parseDates(dates: string[])`** - Takes an array of date ranges using a delimiter between dates in the string format `FormatDateString ('YYYY-MM-DD')`. Returns an array of dates in the string format `FormatDateString ('YYYY-MM-DD')`. | ||
```ts | ||
import { parseDates } from 'vanilla-calendar-pro/utils'; | ||
parseDates(['2024-12-12:2024-12-15']) // return: ['2024-12-12', '2024-12-13', '2024-12-14', '2024-12-15'] | ||
``` | ||
|
||
2. **`getDateString(date: Date)`** — Takes a date of type `Date`. Returns the date in the string format `FormatDateString ('YYYY-MM-DD')`. | ||
```ts | ||
import { getDateString } from 'vanilla-calendar-pro/utils'; | ||
getDateString(new Date('24.12.2024')) // return: 2024-12-24 | ||
``` | ||
|
||
3. **`getDate(date: FormatDateString)`** — Takes a date in string format, e.g., `FormatDateString ('YYYY-MM-DD')`. Returns a date of type `Date`. | ||
```ts | ||
import { getDate } from 'vanilla-calendar-pro/utils'; | ||
getDate(new Date('2024-12-12')) // return: Tue Dec 24 2024 00:00:00 GMT | ||
``` | ||
|
||
4. **`getWeekNumber(date: FormatDateString, weekStartDay: WeekDayID)`** - Takes a date in string format `FormatDateString ('YYYY-MM-DD')` and the week start day, specifically its `id` of type `number` from 0 to 6. Returns an object `{ year: yearNumber, week: weekNumber }` for the date specified in the arguments. | ||
```ts | ||
import { getWeekNumber } from 'vanilla-calendar-pro/utils'; | ||
getWeekNumber('2024-12-12', 1) // return: {year: 2024, week: 50} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- | ||
title: Утилиты | ||
description: Узнайте о 4 удобных утилитах для работы с датами, поставляемых с Vanilla Calendar Pro. Эти функции позволяют форматировать даты, преобразовывать их в нужные форматы и определять номера недель. | ||
section: 2 | ||
--- | ||
|
||
# Утилиты | ||
|
||
Вместе с календарем устанавливаются его утилиты, с помощью которых можно удобно форматировать даты. | ||
|
||
Всего есть 4 утилиты, они являются функциями и вы можете использовать их в любом месте вашего кода, даже без календаря. | ||
|
||
1. **`parseDates(dates: string[])`** - принимает на вход массив диапазонов дат с использованием разделителя между датами в строковом формате типа `FormatDateString ('YYYY-MM-DD')`. Возвращает массив дат в строковом формате типа `FormatDateString ('YYYY-MM-DD')`. | ||
```ts | ||
import { parseDates } from 'vanilla-calendar-pro/utils'; | ||
parseDates(['2024-12-12:2024-12-15']) // возвращает: ['2024-12-12', '2024-12-13', '2024-12-14', '2024-12-15'] | ||
``` | ||
|
||
2. **`getDateString(date: Date)`** — принимает на вход дату типа `Date`. Возвращает дату в строковом формате типа `FormatDateString ('YYYY-MM-DD')`. | ||
```ts | ||
import { getDateString } from 'vanilla-calendar-pro/utils'; | ||
getDateString(new Date('24.12.2024')) // возвращает: 2024-12-24 | ||
``` | ||
|
||
3. **`getDate(date: FormatDateString)`** — принимает дату в строковом формате, например `FormatDateString ('YYYY-MM-DD')`. Возвращает дату типа `Date`. | ||
```ts | ||
import { getDate } from 'vanilla-calendar-pro/utils'; | ||
getDate(new Date('2024-12-12')) // возвращает: Tue Dec 24 2024 00:00:00 GMT | ||
``` | ||
|
||
4. **`getWeekNumber(date: FormatDateString, weekStartDay: WeekDayID)`** - принимает на вход дату в строковом формате типа `FormatDateString ('YYYY-MM-DD')` и день начала недели, а точнее его `id` с типом `number` от 0 до 6. Возвращает объект `{ year: yearNumber, week: weekNumber }` для даты, указанной в аргументах. | ||
```ts | ||
import { getWeekNumber } from 'vanilla-calendar-pro/utils'; | ||
getWeekNumber('2024-12-12', 1) // возвращает: {year: 2024, week: 50} | ||
``` |