Skip to content

Commit 83c9562

Browse files
Merge pull request #36 from DHTMLX/v9.1.3
v9.1.3
2 parents dc92600 + 176a64b commit 83c9562

17 files changed

Lines changed: 7687 additions & 3019 deletions

File tree

docs/api/config/date_format.md

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,35 @@ If you want to use a custom format, you can either change this config, or redefi
3030

3131
## Loading dates in ISO format
3232

33-
You can use ISO date format in Gantt. For this, you need to redefine functions that parse and serialize dates in Gantt:
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.
34+
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.
36+
37+
The `date_format` config still applies to non-ISO date strings.
38+
39+
:::tip Gantt v9.1.2 and earlier
40+
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:
3441

3542
~~~js
36-
gantt.templates.parse_date = function(date) {
43+
gantt.templates.parse_date = function(date) {
3744
return new Date(date);
3845
};
39-
gantt.templates.format_date = function(date) {
46+
gantt.templates.format_date = function(date) {
4047
return date.toISOString();
4148
};
4249
~~~
4350

51+
:::
52+
53+
For more details, see [Loading dates in ISO format](guides/loading.md#loading-dates-in-iso-format).
54+
4455
## Changing the date format dynamically
4556

4657
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:
4758

4859
~~~js
49-
var cfg = gantt.config;
50-
var strToDate = gantt.date.str_to_date(cfg.date_format, cfg.server_utc);
60+
const cfg = gantt.config;
61+
const strToDate = gantt.date.str_to_date(cfg.date_format, cfg.server_utc);
5162

5263
gantt.templates.parse_date = function(date){
5364
return strToDate (date);

docs/api/other/date.md

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,17 +197,35 @@ var firstDay = gantt.date.month_start(new Date(2019, 05, 29, 14, 30));
197197
---
198198

199199
#### parseDate(date, format)
200-
Converts a string of the specified format to a Date object
200+
201+
Converts a date string to a Date object. This method is called during [gantt.load()](api/method/load.md) and [gantt.parse()](api/method/parse.md) to parse task and link date properties.
201202

202203
**Parameters**:
203-
- `date` - (string) - The date string
204-
- `format` - (string) - The date format (see guides/date-format.md)
204+
- `date` - (string) - The date string to parse
205+
- `format` - (string | function, optional) - A date format string (see [Date Format Specification](guides/date-format.md)) or a custom parser function `(dateStr) => Date`
205206

206207
**Returns**: Date - The parsed date object
207208

208-
**Example**:
209+
**Parsing logic** (since v9.1.3):
210+
211+
1. **ISO 8601 check** - if the string matches an ISO 8601 pattern (e.g. `"2026-01-06"`, `"2026-01-06T10:30:00Z"`), it is parsed directly and `format` is not consulted. If the user has explicitly overridden `gantt.templates.parse_date`, ISO auto-detection is skipped and the user's function handles all parsing.
212+
2. **`format` argument** - if provided as a string, it is converted to a parser function via `gantt.date.str_to_date(format)`; if provided as a function, it is called directly
213+
3. **Fallback** - if no `format` is provided, the [parse_date](api/template/parse_date.md) template is used
214+
215+
**Examples**:
209216
~~~js
210-
var date = gantt.date.parseDate("29/06/2019","%d/%m/%Y"); //-> 29 June, 2019 00:00:00
217+
// with an explicit format string
218+
var date = gantt.date.parseDate("29/06/2019", "%d/%m/%Y");
219+
// -> 29 June, 2019 00:00:00
220+
221+
// ISO string - parsed automatically, format is ignored
222+
var date2 = gantt.date.parseDate("2026-01-06T10:30:00Z");
223+
// -> 6 January, 2026 10:30:00 UTC
224+
225+
// with a custom parser function
226+
var date3 = gantt.date.parseDate("Jan 6, 2026", function(str) {
227+
return new Date(str);
228+
});
211229
~~~
212230

213231
---

docs/api/template/format_date.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,25 @@ Check [Date Format Specification](guides/date-format.md).
3434

3535
## Loading dates in ISO format
3636

37-
You can use ISO date format in Gantt. For this, you need to redefine functions that parse and serialize dates in Gantt:
37+
Since v9.1.3, when ISO 8601 dates are detected on input, dates are serialized back as ISO strings automatically - unless you explicitly override this template. If you define a custom `format_date` function, it takes priority and is used for all dates, including ISO.
38+
39+
:::tip Gantt v9.1.2 and earlier
40+
In versions before v9.1.3, ISO dates were not detected automatically. If you are using an older version, you need to override the templates to handle ISO strings:
3841

3942
~~~js
40-
gantt.templates.parse_date = function(date) {
43+
gantt.templates.parse_date = function(date) {
4144
return new Date(date);
4245
};
43-
gantt.templates.format_date = function(date) {
46+
gantt.templates.format_date = function(date) {
4447
return date.toISOString();
4548
};
4649
~~~
4750

51+
In v9.1.3+, these overrides are unnecessary for ISO dates.
52+
:::
53+
54+
For more details, see [Loading dates in ISO format](guides/loading.md#loading-dates-in-iso-format).
55+
4856
## Changing the date format dynamically
4957

5058
If you need to change the [date format](api/config/date_format.md) dynamically, it is necessary to modify the [parse_date](api/template/parse_date.md) template in the following way:

docs/api/template/parse_date.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,24 +32,33 @@ gantt.templates.parse_date = function(date){
3232

3333
### Details
3434

35-
This function is called from **gantt.load()** or **gantt.parse()** call to parse the *start_date/end_date* properties of tasks, if they are provided in the string format.
36-
This function can be redefined if you use a custom format that the default method can't parse. Check [Date Format Specification](guides/date-format.md).
35+
This function can be called from **gantt.load()** or **gantt.parse()** call to parse date properties of tasks, if they are provided in the string format.
36+
37+
This function can be redefined if you use a custom date format that the default method can't parse. Check [Date Format Specification](guides/date-format.md).
3738

3839
[Read more about date objects](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date).
3940

4041
## Loading dates in ISO format
4142

42-
You can use ISO date format in Gantt. For this, you need to redefine functions that parse and serialize dates in Gantt:
43+
Since v9.1.3, Gantt automatically detects and parses ISO 8601 date strings. A manual `parse_date` override is not needed for ISO dates. However, if you do override this template, your function takes priority - ISO auto-detection is skipped and your function handles all date strings.
44+
45+
:::tip Gantt v9.1.2 and earlier
46+
In versions before v9.1.3, ISO dates were not detected automatically. If you are using an older version, you need to override this template to handle ISO strings:
4347

4448
~~~js
45-
gantt.templates.parse_date = function(date) {
49+
gantt.templates.parse_date = function(date) {
4650
return new Date(date);
4751
};
48-
gantt.templates.format_date = function(date) {
52+
gantt.templates.format_date = function(date) {
4953
return date.toISOString();
5054
};
5155
~~~
5256

57+
In v9.1.3+, these overrides are unnecessary for ISO dates.
58+
:::
59+
60+
For more details, see [Loading dates in ISO format](guides/loading.md#loading-dates-in-iso-format).
61+
5362
### Related API
5463
- [parse](api/method/parse.md)
5564
- [load](api/method/load.md)

docs/guides/conversion-templates.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,7 @@ sidebar_label: "Templates for Date Conversion"
88
- [parse_date](api/template/parse_date.md) - converts date string into a Date object
99
- [format_date](api/template/format_date.md) - converts a date object to a date string. Used to send data back to the server
1010

11+
:::note
12+
Since v9.1.3, ISO 8601 dates are handled automatically without overriding these templates. See [Loading dates in ISO format](guides/loading.md#loading-dates-in-iso-format).
13+
:::
14+

docs/guides/date-format.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,3 @@ While specifying the format for dates you can use any character from the followi
3636
- **%A** - displays **AM** (for times from midnight until noon) and **PM** (for times from noon until midnight).
3737

3838
For example, if you want to present 1st June 2019 as 01/06/2019, you should specify "%d/%m/%Y".
39-

docs/guides/loading.md

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,38 @@ The **end_date** has a higher priority than the **duration** parameter. If there
164164

165165
## Loading dates in ISO format
166166

167-
You can use ISO date format in Gantt. For this, you need to redefine functions that parse and serialize dates in Gantt:
167+
Since v9.1.3, Gantt automatically detects and parses ISO 8601 date strings. No configuration is needed.
168+
169+
Supported formats:
170+
171+
- `2026-01-06` - date only
172+
- `2026-01-06T10:30:00` - date and time
173+
- `2026-01-06T10:30:00.000` - date and time with milliseconds
174+
- `2026-01-06T10:30:00.000Z` - UTC
175+
- `2026-01-06T10:30:00+02:00` - with timezone offset
176+
177+
~~~js
178+
gantt.parse({
179+
tasks: [
180+
{ id: 2, text: "Task #1", start_date: "2026-01-06T10:30:00Z", duration: 3 }
181+
],
182+
links: []
183+
});
184+
// ISO dates are parsed automatically - no template overrides needed
185+
~~~
186+
187+
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. If the input contains a mix of date-only and full datetime strings, all dates are serialized as full datetime.
188+
189+
:::note
190+
Date-only strings (e.g., `"2026-01-06"`) are parsed as local midnight when `server_utc` is set to `false` (the default).
191+
:::
192+
193+
:::note
194+
If you explicitly override `gantt.templates.parse_date` or `gantt.templates.format_date`, your functions take priority over ISO auto-detection and auto-serialization.
195+
:::
196+
197+
:::tip Gantt v9.1.2 and earlier
198+
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:
168199

169200
~~~js
170201
gantt.templates.parse_date = (date) => {
@@ -176,6 +207,9 @@ gantt.templates.format_date = (date) => {
176207
};
177208
~~~
178209

210+
In v9.1.3+, these templates are still used as the fallback for **non-ISO** date strings. See [gantt.date.parseDate()](api/other/date.md#parsedatedate-format) for the full parsing pipeline.
211+
:::
212+
179213
## Changing the date format dynamically
180214

181215
If you need to change the [date format](api/config/date_format.md) dynamically, it is necessary to modify the [parse_date](api/template/parse_date.md) template in the following way:

docs/integrations/ai-tools/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ This section collects materials for using AI with DHTMLX Gantt in two ways:
1515

1616
If you're using an AI app builder to generate or modify your UI, start here:
1717

18-
- [Lovable AI](./lovable-ai/) integrate DHTMLX [React Gantt](./../react/) into a Lovable-generated app and improve results using prompts, Knowledge Base, and MCP.
18+
- [Lovable AI](./lovable-ai/) - integrate DHTMLX [React Gantt](./../react/) into a Lovable-generated app and improve results using prompts, Knowledge Base, and MCP.
1919

2020
## MCP Server
2121

22-
- [DHTMLX MCP Server](./mcp-server/) connect an AI tool to up-to-date DHTMLX documentation and API reference.
22+
- [DHTMLX MCP Server](./mcp-server/) - connect an AI tool to up-to-date DHTMLX documentation and API reference.
2323

2424

2525
## AI features inside your app

docs/integrations/react/state/jotai.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -246,13 +246,17 @@ export default function DemoJotai() {
246246

247247
Let's configure the Gantt chart's templates which define date formatting and parsing for consistent data handling:
248248

249+
:::note
250+
Since v9.1.3, Gantt automatically detects ISO date strings and these template overrides are no longer needed. They are shown here for compatibility with earlier Gantt versions. See [Loading dates in ISO format](guides/loading.md#loading-dates-in-iso-format).
251+
:::
252+
249253
~~~tsx
250-
const templates: ReactGanttProps['templates'] = useMemo(
251-
() => ({
252-
format_date: (date: Date) => date.toISOString(),
253-
parse_date: (value: string) => new Date(value),
254-
}),
255-
[]
254+
const templates: ReactGanttProps['templates'] = useMemo(
255+
() => ({
256+
format_date: (date: Date) => date.toISOString(),
257+
parse_date: (value: string) => new Date(value),
258+
}),
259+
[]
256260
);
257261
~~~
258262

docs/integrations/react/state/mobx.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -235,13 +235,17 @@ We wrap our component with `observer()` from `mobx-react-lite` to automatically
235235

236236
Let's configure the Gantt chart's templates which define date formatting and parsing for consistent data handling:
237237

238+
:::note
239+
Since v9.1.3, Gantt automatically detects ISO date strings and these template overrides are no longer needed. They are shown here for compatibility with earlier Gantt versions. See [Loading dates in ISO format](guides/loading.md#loading-dates-in-iso-format).
240+
:::
241+
238242
~~~tsx
239-
const templates: ReactGanttProps['templates'] = useMemo(
240-
() => ({
241-
format_date: (d) => d.toISOString(),
242-
parse_date: (s) => new Date(s),
243-
}),
244-
[]
243+
const templates: ReactGanttProps['templates'] = useMemo(
244+
() => ({
245+
format_date: (d) => d.toISOString(),
246+
parse_date: (s) => new Date(s),
247+
}),
248+
[]
245249
);
246250
~~~
247251

0 commit comments

Comments
 (0)