Skip to content

Commit

Permalink
Move xref for time formats to the intro page in docs and update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
lsgunnlsgunn committed Nov 6, 2024
1 parent 5650ae1 commit c6fe1ec
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions docs/builtins/Time/parse-time.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
## parse-time
Use `parse-time` to construct time from a UTC value using a specified format. See ["Time Formats" docs](https://docs.kadena.io/reference/functions/time#time-formatsh-299815639) for supported formats.

Use `parse-time` to construct a formatted time string from a UTC value using a specified format.
The following table provides a summary of common time formatting codes:

| Format | Purpose |
| --- | --- |
| %Y | Year, no padding. |
| %m | Month of the year, zero-padded to two characters, "01"–"12" |
| %d | Day of the month, zero-padded to two characters, "01"–"31" |
| %H | Hour of the day using a 24-hour clock, zero-padded to two characters, "00"–"23" |
| %M | Minute of of the hour, zero0-padded to two characters, "00"–"59" |
| %S | Second of the minute, zero-padded to two characters, "00"–"60" |
| %N | ISO 8601 style numeric time zone (for example, "-06:00" or "+01:00")|

There are many other formatting options.
For example, you can replace the numeric representing the month of the year with the short or long name for the month.
For information about all of the formats supported, see [Time formats](/pact-5/Time/time-functions#time-formats).

### Basic syntax

Expand All @@ -25,8 +41,8 @@ The `parse-time` function returns a time value constructed from the provided UTC
The following example demonstrates the use of `parse-time` in the Pact REPL:

```pact
pact>(parse-time "%F" "2016-09-12")
2016-09-12 00:00:00 UTC
pact> (parse-time "%F" "2024-11-06")
"2024-11-06T00:00:00Z"
```

In this example, `parse-time` is used to construct a time value from the UTC value "2016-09-12" using the format "%F".
In this example, `parse-time` is used to construct a time value using the the ISO 8601 standard specified by the "%F" format from the UTC value "2024-11-06".

0 comments on commit c6fe1ec

Please sign in to comment.