This repository was archived by the owner on Sep 18, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
[master < T618] Add docs for date module #999
Merged
+145
−0
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,143 @@ | ||
| --- | ||
| id: date | ||
| title: date | ||
| sidebar_label: date | ||
| --- | ||
|
|
||
| import Tabs from '@theme/Tabs'; | ||
| import TabItem from '@theme/TabItem'; | ||
| import RunOnSubgraph from '../../templates/_run_on_subgraph.mdx'; | ||
|
|
||
| export const Highlight = ({children, color}) => ( | ||
| <span | ||
| style={{ | ||
| backgroundColor: color, | ||
| borderRadius: '2px', | ||
| color: '#fff', | ||
| padding: '0.2rem', | ||
| }}> | ||
| {children} | ||
| </span> | ||
| ); | ||
|
|
||
| The `date` module provides various utilities to handle date and time operations within the Cypher Query Language. These functions can be used in conjunction with other Cypher expressions to handle date-related tasks such as formatting, parsing, comparisons, and arithmetic, thus enhancing the capabilities of Memgraph for managing time-based data. | ||
|
|
||
| [](https://github.com/memgraph/mage/tree/main/python/date.py) | ||
|
|
||
| | Trait | Value | | ||
| | ------------------- | ----------------------------------------------------- | | ||
| | **Module type** | <Highlight color="#FB6E00">**algorithm**</Highlight> | | ||
| | **Implementation** | <Highlight color="#FB6E00">**C++**</Highlight> | | ||
| | **Graph direction** | <Highlight color="#FB6E00">**directed**</Highlight>/<Highlight color="#FB6E00">**undirected**</Highlight> | | ||
| | **Edge weights** | <Highlight color="#FB6E00">**weighted**</Highlight>/<Highlight color="#FB6E00">**unweighted**</Highlight> | | ||
| | **Parallelism** | <Highlight color="#FB6E00">**sequential**</Highlight> | | ||
|
|
||
| ### Procedures | ||
|
|
||
| ### `format(time, unit, format, timezone)` | ||
|
|
||
| Returns a string representation of time value using the specified unit, specified format, and specified time zone. | ||
|
|
||
| #### Input: | ||
|
|
||
| - `time: int` ➡ time passed since the Unix epoch. | ||
| - `unit: str (default="ms")` ➡ unit of the given time. | ||
| - `format: str (default="%Y-%m-%d %H:%M:%S %Z")` ➡ pattern to be formatted to. | ||
| - `timezone: str (default="UTC")` ➡ timezone to be used. | ||
|
|
||
| :::info | ||
|
|
||
| The unit parameter supports the following values: | ||
| - "ms" for milliseconds | ||
| - "s" for seconds | ||
| - "m" for minutes | ||
| - "h" for hours | ||
| - "d" for days | ||
|
|
||
| ::: | ||
|
|
||
| :::info | ||
|
|
||
| The format parameter supports values defined under [Python strftime format codes](https://docs.python.org/3/library/datetime.html#strftime-and-strptime-format-codes). | ||
|
|
||
| ::: | ||
|
|
||
| :::info | ||
|
|
||
| The timezone parameter can be specified with the database TZ identifier (text) name, as listed for [timezones](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones). | ||
|
|
||
| ::: | ||
|
|
||
| #### Output: | ||
|
|
||
| - `formatted: str` ➡ received time in the specified format. | ||
|
|
||
| #### Usage: | ||
|
|
||
| ```cypher | ||
| CALL date.format(74976, "h", "%Y/%m/%d %H:%M:%S %Z", "Mexico/BajaNorte") | ||
| YIELD formatted RETURN formatted; | ||
| ``` | ||
|
|
||
| ```plaintext | ||
| +-------------------------------+ | ||
| | formatted | | ||
| +-------------------------------+ | ||
| | "1978/07/21 17:00:00 PDT" | | ||
| +-------------------------------+ | ||
| ``` | ||
|
|
||
|
|
||
| ### `parse(time, unit, format, timezone)` | ||
|
|
||
| Parses the date string using the specified format and specified timezone into the specified time unit. | ||
|
|
||
| #### Input: | ||
|
|
||
| - `time: str` ➡ a datetime. | ||
| - `unit: str (default="ms")` ➡ unit to be parsed to. | ||
| - `format: str (default="%Y-%m-%d %H:%M:%S")` ➡ format of the given DateTime. | ||
| - `timezone: str (default="UTC")` ➡ timezone to be used. | ||
|
|
||
| :::info | ||
|
|
||
| The unit parameter supports the following values: | ||
| - "ms" for milliseconds | ||
| - "s" for seconds | ||
| - "m" for minutes | ||
| - "h" for hours | ||
| - "d" for days | ||
|
|
||
| ::: | ||
|
|
||
| :::info | ||
|
|
||
| The format parameter supports values defined under [Python strftime format codes](https://docs.python.org/3/library/datetime.html#strftime-and-strptime-format-codes). | ||
|
|
||
| ::: | ||
|
|
||
| :::info | ||
|
|
||
| The timezone parameter can be specified with the database TZ identifier (text) name, as listed for [timezones](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones). | ||
|
|
||
| ::: | ||
|
|
||
| #### Output: | ||
|
|
||
| - `parsed: int` ➡ number of time units that have elapsed since the Unix epoch. | ||
|
|
||
| #### Usage: | ||
|
|
||
| ```cypher | ||
| CALL date.parse("2023/08/03 14:30:00", "h", "%Y/%m/%d %H:%M:%S", "Europe/Zagreb") | ||
| YIELD parsed RETURN parsed; | ||
| ``` | ||
|
|
||
| ```plaintext | ||
| +---------------------+ | ||
| | parsed | | ||
| +---------------------+ | ||
| | 469740 | | ||
| +---------------------+ | ||
| ``` | ||
|
|
||
This file contains hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IF you have these many info boxes they kind of start losing meaning... :)
It's just regular text and info about the module
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like it this way because it draws attention and those infos are really important since the usage of procedures is different from neo4j so I wanted it to be highlighted