From c6fe1ecfa26481407a00a0c810b5edb0f4704625 Mon Sep 17 00:00:00 2001 From: Lisa Gunn Date: Wed, 6 Nov 2024 13:46:13 -0800 Subject: [PATCH] Move xref for time formats to the intro page in docs and update examples --- docs/builtins/Time/parse-time.md | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/docs/builtins/Time/parse-time.md b/docs/builtins/Time/parse-time.md index fdbaa27e2..924c46e69 100644 --- a/docs/builtins/Time/parse-time.md +++ b/docs/builtins/Time/parse-time.md @@ -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 @@ -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".