Skip to content
This repository has been archived by the owner on Sep 18, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1006 from memgraph/E-add-temporal-docs
Browse files Browse the repository at this point in the history
[master < E-temporal] Add docs for temporal module
  • Loading branch information
ind1xa authored Sep 1, 2023
2 parents 599cdad + 4b55e35 commit b292e61
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 0 deletions.
68 changes: 68 additions & 0 deletions mage/query-modules/python/temporal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
---
id: temporal
title: temporal
sidebar_label: temporal
---

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 `temporal` module enables more sophisticated manipulation, conversion, and calculation of date and time. These functions handle temporal (time-related) operations and offer extended capabilities compared to the [`date`](date.md) functions.

[![docs-source](https://img.shields.io/badge/source-temporal-FB6E00?logo=github&style=for-the-badge)](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(temporal, format)`

Formats a temporal value.

#### Input:

- `temporal: Any` ➡ temporal value (date, time, datetime, duration) to be formatted.
- `format: str` ➡ the wanted format.

:::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).

:::

#### Output:

- `formatted: str` ➡ received temporal value in the specified format.

#### Usage:

```cypher
CALL temporal.format(duration({minute: 127}), "%H:%M:%S") YIELD formatted RETURN formatted;
```

```plaintext
+-----------------------+
| formatted |
+-----------------------+
| "02:07:00" |
+-----------------------+
```
1 change: 1 addition & 0 deletions mage/templates/_mage_spells.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
| [node_similarity](/mage/query-modules/cpp/node-similarity) | C++ | A module that contains similarity measures for calculating the similarity between two nodes. |
| [pagerank](/mage/query-modules/cpp/pagerank) | C++ | Algorithm that yields the influence measurement based on the recursive information about the connected nodes influence. |
| [set_cover](/mage/query-modules/python/set-cover) | Python | An algorithm for finding the minimum cost subcollection of sets that covers all elements of a universe. |
| [temporal](/mage/query-modules/python/temporal) | Python | A module that provides functions to handle temporal (time-related) operations and offers extended capabilities compared to the date module. |
| [text](/mage/query-modules/cpp/text) | C++ | A module for manipulating strings. |
| [tsp](/mage/query-modules/python/tsp) | Python | An algorithm for finding the shortest possible route that visits each vertex exactly once. |
| [union_find](/mage/query-modules/python/union-find) | Python | A module with an algorithm that enables the user to check whether the given nodes belong to the same connected component. |
Expand Down
1 change: 1 addition & 0 deletions sidebars/sidebarsMAGE.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ module.exports = {
"query-modules/cpp/pagerank-online",
"query-modules/cpp/periodic",
"query-modules/python/set-cover",
"query-modules/python/temporal",
"query-modules/python/temporal-graph-networks",
"query-modules/cpp/text",
"query-modules/python/tsp",
Expand Down

0 comments on commit b292e61

Please sign in to comment.