mirror of
https://github.com/zadam/trilium.git
synced 2025-12-24 00:59:55 +01:00
docs(technical): dayjs intro & supported plugins
This commit is contained in:
35
docs/User Guide/!!!meta.json
vendored
35
docs/User Guide/!!!meta.json
vendored
@@ -15928,6 +15928,41 @@
|
||||
],
|
||||
"dataFileName": "Backend API.dat",
|
||||
"attachments": []
|
||||
},
|
||||
{
|
||||
"isClone": false,
|
||||
"noteId": "ApVHZ8JY5ofC",
|
||||
"notePath": [
|
||||
"pOsGYCXsbNQG",
|
||||
"CdNpE2pqjmI6",
|
||||
"GLks18SNjxmC",
|
||||
"ApVHZ8JY5ofC"
|
||||
],
|
||||
"title": "Day.js",
|
||||
"notePosition": 30,
|
||||
"prefix": null,
|
||||
"isExpanded": false,
|
||||
"type": "text",
|
||||
"mime": "text/html",
|
||||
"attributes": [
|
||||
{
|
||||
"type": "label",
|
||||
"name": "shareAlias",
|
||||
"value": "day.js",
|
||||
"isInheritable": false,
|
||||
"position": 30
|
||||
},
|
||||
{
|
||||
"type": "label",
|
||||
"name": "iconClass",
|
||||
"value": "bx bx-calendar",
|
||||
"isInheritable": false,
|
||||
"position": 40
|
||||
}
|
||||
],
|
||||
"format": "markdown",
|
||||
"dataFileName": "Day.js.md",
|
||||
"attachments": []
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
31
docs/User Guide/User Guide/Scripting/Script API/Day.js.md
vendored
Normal file
31
docs/User Guide/User Guide/Scripting/Script API/Day.js.md
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
# Day.js
|
||||
Day.js is a date manipulation library that's used by Trilium, but it's also shared with both front-end and back-end scripts. For more information about the library itself, consult the [official documentation](https://day.js.org/en/).
|
||||
|
||||
## How to use
|
||||
|
||||
The `dayjs` method is provided directly in the `api` global:
|
||||
|
||||
```javascript
|
||||
const date = api.dayjs();
|
||||
api.log(date.format("YYYY-MM-DD"));
|
||||
```
|
||||
|
||||
## Plugins
|
||||
|
||||
Day.js uses a modular, plugin-based architecture. Generally these plugins must be imported, but this process doesn't work inside Trilium scripts due to the use of a bundler.
|
||||
|
||||
Since v0.100.0, the same set of plugins is available for both front-end and back-end scripts.
|
||||
|
||||
The following Day.js plugins are directly integrated into Trilium:
|
||||
|
||||
* [AdvancedFormat](https://day.js.org/docs/en/plugin/advanced-format)
|
||||
* [Duration](https://day.js.org/docs/en/plugin/duration), since v0.100.0.
|
||||
* [IsBetween](https://day.js.org/docs/en/plugin/is-between)
|
||||
* [IsoWeek](https://day.js.org/docs/en/plugin/iso-week)
|
||||
* [IsSameOrAfter](https://day.js.org/docs/en/plugin/is-same-or-after)
|
||||
* [IsSameOrBefore](https://day.js.org/docs/en/plugin/is-same-or-before)
|
||||
* [QuarterOfYear](https://day.js.org/docs/en/plugin/quarter-of-year)
|
||||
* [UTC](https://day.js.org/docs/en/plugin/utc)
|
||||
|
||||
> [!NOTE]
|
||||
> If another Day.js plugin might be needed for scripting purposes, feel free to open a feature request for it. Depending on the size of the plugin and the potential use of it inside the Trilium code base, it has a chance of being integrated.
|
||||
Reference in New Issue
Block a user