Skip to content

Commit 4698d78

Browse files
Merge pull request #35 from mlakatkou/GS-3358
[update] date article
2 parents 40319e8 + 0fdf1e8 commit 4698d78

1 file changed

Lines changed: 63 additions & 62 deletions

File tree

docs/api/other/date.md

Lines changed: 63 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -15,123 +15,124 @@ description: "a set of date formatting methods"
1515

1616
### Details
1717

18-
The **date** object provides the following methods:
18+
The `date` object provides the following methods:
1919

20-
- **add**(date, number, unit) - adds/subtracts the specified time interval to/from the date
21-
- **date** - (<i>Date</i>) the date object that you need to add a time to/subtract a time from
22-
- **number** - (<i>number</i>) the number of units to add. If this number is positive - the time will be added to the date, if negative - the time will be subtracted
23-
- **unit** - (<i>'minute', 'hour', 'day', 'week', 'month', 'year'</i>) the time unit
20+
- `add()` - adds/subtracts the specified time interval to/from the date
21+
- `date` - (<i>Date</i>) the date object that you need to add time to/subtract time from
22+
- `number` - (<i>number</i>) the number of units to add. If this number is positive, the time will be added to the date; if negative, the time will be subtracted
23+
- `unit` - (<i>'minute', 'hour', 'day', 'week', 'month', 'year'</i>) the time unit
2424

2525
~~~js
26-
//adds 1 year to the specified date: 29 June, 2019 -> 29 June, 2014
27-
var newDate = scheduler.date.add(new Date(2019, 05, 29), 1, 'year');
26+
// adds 1 year to the specified date: 29 June, 2027 -> 29 June, 2028
27+
const newDate = scheduler.date.add(new Date(2027, 5, 29), 1, 'year');
2828
~~~
2929

30-
- **convert_to_utc**(date) - converts local time to UTC
31-
- **date** - (<i>Date</i>) the date object to convert
30+
- `convert_to_utc()` - converts local time to UTC
31+
- `date` - (<i>Date</i>) the date object to convert
3232

3333
~~~js
34-
//29 June, 2019 14:00 (local time) -> 29 June, 2019 12:00 (utc)
35-
var time = scheduler.date.convert_to_utc(new Date(2019, 05, 29, 14, 00));
34+
// 29 June, 2027 14:00 (local time) -> 29 June, 2027 12:00 (UTC)
35+
const time = scheduler.date.convert_to_utc(new Date(2027, 5, 29, 14, 0));
3636
~~~
3737

38-
- **copy**(date)- makes a copy of a Date object
39-
- **date** - (<i>Date</i>) the date object to copy
38+
- `copy()` - makes a copy of a Date object
39+
- `date` - (<i>Date</i>) the date object to copy
4040

4141
~~~js
42-
var copy = scheduler.date.copy(new Date(2019, 05, 29));// -> 29 June, 2019
42+
const copy = scheduler.date.copy(new Date(2027, 5, 29)); // -> 29 June, 2027
4343
~~~
4444

45-
- **date_part**(date) - resets the time part of the provided date to 00:00:00
46-
- **date** - (<i>Date</i>) the date object to format
45+
- `date_part()` - resets the time part of the provided date to 00:00:00
46+
- `date` - (<i>Date</i>) the date object to format
4747

4848
~~~js
49-
//29 June, 2019 14:30:10 -> 29 June, 2019 00:00:00
50-
var date = scheduler.date.date_part(new Date(2019, 05, 29, 14, 30, 10));
49+
// 29 June, 2027 14:30:10 -> 29 June, 2027 00:00:00
50+
const date = scheduler.date.date_part(new Date(2027, 5, 29, 14, 30, 10));
5151
~~~
5252

53-
- **date_to_str**(format, utc) - returns a function that converts a Date object to a string of the specified format
54-
- **format**> - (<i>string</i>) the date format (see [Date Format Specification](guides/settings-format.md))
55-
- **utc** - (<i>boolean</i>) specifies whether local time should be converted to UTC
53+
- `date_to_str()` - returns a function that converts a Date object to a string of the specified format
54+
Parameters: `format` - (<i>string</i>) the date format (see [Date Format Specification](guides/settings-format.md))
55+
`utc` - (<i>boolean</i>) specifies whether local time should be converted to UTC
5656

5757
~~~js
58-
var formatFunc = scheduler.date.date_to_str("%d/%m/%Y");
59-
var date = formatFunc(new Date(2019, 05, 29)); // -> "29/06/2019"
58+
const formatFunc = scheduler.date.date_to_str("%d/%m/%Y");
59+
const date = formatFunc(new Date(2027, 5, 29)); // -> "29/06/2027"
6060
~~~
6161

62-
- **day_start**(date) - resets the time part of the provided date to 00:00:00. Alias of the <b>date_part</b> method. Used by the Day view to set the display date and can be redefined to provide the default behaviour
63-
- **date** - (<i>Date</i>) the date object to format
62+
- `day_start()` - resets the time part of the provided date to 00:00:00. Alias of the `date_part()` method. Used by the Day view to set the display date and can be redefined to provide the default behavior
63+
Parameters: `date` - (<i>Date</i>) the date object to format
6464

6565
~~~js
66-
//29 June, 2019 14:30:10 -> 29 June, 2019 00:00:00
67-
var date = scheduler.date.day_start(new Date(2019, 05, 29, 14, 30, 10));
66+
// 29 June, 2027 14:30:10 -> 29 June, 2027 00:00:00
67+
const date = scheduler.date.day_start(new Date(2027, 5, 29, 14, 30, 10));
6868
~~~
6969

70-
>**Note**, the date passed to the method will be actually changed. You may prevent the original date from being changed by wrapping the input date with *new Date*. For instance:
70+
> **Note**, the date passed to the method will actually be changed. You may prevent the original date from being changed by wrapping the input date with `new Date()`. For instance:
7171
7272
~~~js
73-
var date1 = new Date(2019, 05, 29, 14, 30, 10))
74-
var date2 = scheduler.date.day_start(new Date(date1))
73+
const originalDate = new Date(2027, 5, 29, 14, 30, 10);
74+
const dayStartDate = scheduler.date.day_start(new Date(originalDate));
7575
~~~
7676

77-
- **getISOWeek**(date)- returns the week number of the date
78-
- **date** - (<i>Date</i>) the date object to format
77+
- `getISOWeek()` - returns the week number of the date
78+
- `date` - (<i>Date</i>) the date object to format
7979

8080
~~~js
81-
var week = scheduler.date.getISOWeek(new Date(2019, 05, 29)); // ->26
81+
const week = scheduler.date.getISOWeek(new Date(2027, 5, 29)); // -> 26
8282
~~~
8383

84-
- **getUTCISOWeek**(date) - returns the week number of the date, but previously converts local time to UTC
85-
- **date** - (<i>Date</i>) the date object to format
84+
- `getUTCISOWeek()` - returns the week number of the date, but previously converts local time to UTC
85+
- `date` - (<i>Date</i>) the date object to format
8686

8787
~~~js
88-
var week = scheduler.date.getUTCISOWeek(new Date(2019, 05, 29)); // ->26
88+
const week = scheduler.date.getUTCISOWeek(new Date(2027, 5, 29)); // -> 26
8989
~~~
9090

91-
- **month_start**(date) - returns a Date object of the first day of the month for the specified date and clears the time part to zero
92-
- **date** - (<i>Date</i>) the date object to format
91+
- `month_start()` - returns a Date object of the first day of the month for the specified date and clears the time part to zero
92+
- `date` - (<i>Date</i>) the date object to format
9393

9494
~~~js
95-
//29 June, 2019 14:30 -> 01 June, 2019 00:00
96-
var firstDay = scheduler.date.month_start(new Date(2019, 05, 29, 14, 30));
95+
// 29 June, 2027 14:30 -> 01 June, 2027 00:00
96+
const firstDay = scheduler.date.month_start(new Date(2027, 5, 29, 14, 30));
9797
~~~
9898

99-
- <span id="strtodate">**str_to_date**(format,utc,parseExact)</span> - returns a function that converts a string of the specified format to a Date object
100-
- **format** - (<i>string</i>) the date format ( see [Date Format Specification](guides/settings-format.md))
101-
- **utc** - (<i>boolean</i>) specifies whether local time should be converted to UTC
102-
- **parseExact** - (<i>boolean</i>) defines whether Scheduler identifies the format of a date automatically (*false*, default) or uses the format passed a user (*true*)
99+
<span id="strtodate"></span>
100+
- `str_to_date()` - returns a function that converts a string of the specified format to a Date object
101+
Parameters: `format` - (<i>string</i>) the date format (see [Date Format Specification](guides/settings-format.md))
102+
`utc` - (<i>boolean</i>) specifies whether local time should be converted to UTC
103+
`parseExact` - (<i>boolean</i>) defines whether Scheduler identifies the format of a date automatically (*false*, default) or uses the format passed by a user (*true*)
103104
~~~js
104-
var formatFunc = scheduler.date.str_to_date("%d/%m/%Y");
105-
var date = formatFunc("29/06/2019"); // -> 29 June, 2019 00:00:00
105+
const formatFunc = scheduler.date.str_to_date("%d/%m/%Y");
106+
const date = formatFunc("29/06/2027"); // -> 29 June, 2027 00:00:00
106107
~~~
107108

108-
- **time_part**(date) - returns the time of a Date object as a number of seconds counted from the midnight (00:00:00)
109-
- **date** - (<i>Date</i>) the date object to format
109+
- `time_part()` - returns the time of a Date object as a number of seconds counted from midnight (00:00:00)
110+
- `date` - (<i>Date</i>) the date object to format
110111
~~~js
111-
var time = scheduler.date.time_part(new Date(2019, 05, 29, 14, 30, 10));
112-
//time -> 52210
112+
const time = scheduler.date.time_part(new Date(2027, 5, 29, 14, 30, 10));
113+
// time -> 52210
113114
~~~
114115

115-
- **to_fixed**(num) - adds the leading zero to numbers less than 10 and returns the result as a string. Doesn't affect numbers from 10
116-
- **num** - (<i>number</i>) the number to format
116+
- `to_fixed()` - adds the leading zero to numbers less than 10 and returns the result as a string. Doesn't affect numbers from 10
117+
- `num` - (<i>number</i>) the number to format
117118

118119
~~~js
119-
var num1 = scheduler.date.to_fixed(2);// ->"02"
120-
var num2 = scheduler.date.to_fixed(10);// ->10
120+
const num1 = scheduler.date.to_fixed(2); // -> "02"
121+
const num2 = scheduler.date.to_fixed(10); // -> 10
121122
~~~
122123

123-
- **week_start**(date) - returns a Date object of the first day of the week for the specified date and clears the time part to zero
124-
- **date** - (<i>Date</i>) the date object to format
124+
- `week_start()` - returns a Date object of the first day of the week for the specified date and clears the time part to zero
125+
- `date` - (<i>Date</i>) the date object to format
125126

126127
~~~js
127-
//29 June, 2019 14:30 -> 24 June, 2019 00:00
128-
var weekStart = scheduler.date.week_start(new Date(2019, 05, 29, 14, 30));
128+
// 29 June, 2027 14:30 -> 28 June, 2027 00:00
129+
const weekStart = scheduler.date.week_start(new Date(2027, 5, 29, 14, 30));
129130
~~~
130131

131-
- **year_start**(date) - returns a Date object of the first day of the year for the specified date and clears the time part to zero
132-
- **date** - (<i>Date</i>) the date object to format
132+
- `year_start()` - returns a Date object of the first day of the year for the specified date and clears the time part to zero
133+
- `date` - (<i>Date</i>) the date object to format
133134

134135
~~~js
135-
//29 June, 2019 14:30 -> 01 January, 2019 00:00
136-
var yearStart = scheduler.date.year_start(new Date(2019, 05, 29, 14, 30));
136+
// 29 June, 2027 14:30 -> 01 January, 2027 00:00
137+
const yearStart = scheduler.date.year_start(new Date(2027, 5, 29, 14, 30));
137138
~~~

0 commit comments

Comments
 (0)