Skip to content

Commit fea79dc

Browse files
Merge pull request #54 from mlakatkou/GS-3269
[update] date_format article
2 parents 43d5cac + 6ee5f9b commit fea79dc

1 file changed

Lines changed: 10 additions & 17 deletions

File tree

docs/api/config/date_format.md

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,23 @@ gantt.load("/data/tasks");
2525

2626
### Details
2727

28-
This config value is used to generate [parse_date](api/template/parse_date.md) and [format_date](api/template/format_date.md) template functions.
29-
If you want to use a custom format, you can either change this config, or redefine **parse_date** and **format_date** templates directly.
28+
This config value is used to generate [`parse_date`](api/template/parse_date.md) and [`format_date`](api/template/format_date.md) template functions.
29+
If you want to use a custom format, you can either change this config, or redefine `parse_date` and `format_date` templates directly.
3030

3131
## Loading dates in ISO format
3232

33-
Since v9.1.3, Gantt automatically detects and parses ISO 8601 date strings. The `date_format` config is not needed for ISO strings - they are recognized and parsed directly.
33+
Since v9.1.3, Gantt automatically detects and parses ISO 8601 date strings. The `date_format` config is not needed for ISO strings - they are recognized and parsed directly.
3434

35-
When ISO dates are detected on input, they are serialized back as ISO strings automatically when passed to the [DataProcessor](guides/server-side.md). Date-only strings (e.g., `"2026-01-06"`) are serialized back as date-only strings, preserving the original format.
35+
When ISO dates are detected on input, they are serialized back as ISO strings automatically when passed to the [DataProcessor](api/method/dataprocessor.md). Date-only strings (e.g., `"2026-01-06"`) are serialized back as date-only strings, preserving the original format.
3636

3737
The `date_format` config still applies to non-ISO date strings.
3838

3939
:::tip Gantt v9.1.2 and earlier
4040
In versions before v9.1.3, ISO dates were not detected automatically. If you are using an older version, you need to override `parse_date` and `format_date` templates to handle ISO strings:
4141

4242
~~~js
43-
gantt.templates.parse_date = function(date) {
44-
return new Date(date);
45-
};
46-
gantt.templates.format_date = function(date) {
47-
return date.toISOString();
48-
};
43+
gantt.templates.parse_date = (date) => new Date(date);
44+
gantt.templates.format_date = (date) => date.toISOString();
4945
~~~
5046

5147
:::
@@ -54,15 +50,13 @@ For more details, see [Loading dates in ISO format](guides/loading.md#loading-da
5450

5551
## Changing the date format dynamically
5652

57-
If you need to change the date format dynamically, it is necessary to modify the [parse_date](api/template/parse_date.md) template in the following way:
53+
If you need to change the date format dynamically, it is necessary to modify the [`parse_date`](api/template/parse_date.md) template in the following way:
5854

5955
~~~js
60-
const cfg = gantt.config;
61-
const strToDate = gantt.date.str_to_date(cfg.date_format, cfg.server_utc);
56+
const config = gantt.config;
57+
const parseDate = gantt.date.str_to_date(config.date_format, config.server_utc);
6258

63-
gantt.templates.parse_date = function(date){
64-
return strToDate (date);
65-
};
59+
gantt.templates.parse_date = (date) => parseDate(date);
6660
~~~
6761

6862
### Related API
@@ -71,4 +65,3 @@ gantt.templates.parse_date = function(date){
7165

7266
### Related Guides
7367
- [Date Format Specification](guides/date-format.md)
74-

0 commit comments

Comments
 (0)