Skip to content

Commit

Permalink
Changes to pact functions for the new docs site
Browse files Browse the repository at this point in the history
  • Loading branch information
lsgunnlsgunn committed Jan 8, 2025
1 parent 99b2594 commit d7d8567
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 121 deletions.
2 changes: 1 addition & 1 deletion docs/builtins/General/describe-namespace.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ To describe the namespace `namespace`, use the following syntax:
### Prerequisites

You must define a namespace with the define-namespace function before you can use the `describe-namespace` function.
For information about defining a namespace, see [define-namespace](/reference/functions/general#define-namespace).
For information about defining a namespace, see [define-namespace](/pact-5/general/define-namespace).

### Arguments

Expand Down
8 changes: 4 additions & 4 deletions docs/builtins/General/namespace.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
## namespace

Use `namespace` to set the current working environment to the specified namespace value.
After you declare the namespace you want to work with, all of the modules and functions you define are contained within that namespace.
Use `namespace` to set the current working environment to the specified namespace value.
After you declare the namespace you want to work with, all of the modules and functions you define are contained within that namespace.

You can access the modules and functions in a namespace by using their fully qualified name.
The fully-qualified name includes the namespace string as a prefix before the module name.
The fully-qualified name includes the namespace string as a prefix before the module name.
For example, if you declare a principal namespace such as `n_14912521e87a6d387157d526b281bde8422371d1` for the module `my-calculator`, you can call functions in the module using a fully-qualified name similar to the following:

`n_14912521e87a6d387157d526b281bde8422371d1.my-calculator.add`
Expand All @@ -13,7 +13,7 @@ If you call the `namespace` function after the initial declaration, Pact creates

### Prerequisites

You must define a namespace before you can set your working context to use the `namespace` function. For information about defining a namespace, see [define-namespace](/reference/functions/general#define-namespace).
You must define a namespace before you can set your working context to use the `namespace` function. For information about defining a namespace, see [define-namespace](/pact-5/general/define-namespace).

### Basic syntax

Expand Down
2 changes: 1 addition & 1 deletion docs/builtins/Guards/create-principal.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Use `create-principal` to create a principal account that unambiguously identifies a specified `guard` predicate function.

For an introduction to principal accounts, see [Accounts, keys, and principals](/learn/accounts).
For an introduction to principal accounts, see [Accounts, keys, and principals](/smart-contracts/accounts).

### Basic syntax

Expand Down
2 changes: 1 addition & 1 deletion docs/builtins/Repl/env-keys.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## env-keys (DEPRECATED)

Use `env-keys` to set the transaction signer keys in older version of the Pact REPL.
The `env-keys` function is deprecated in favor of [`env-sigs`](/reference/functions/repl-only-functions#env-sigsh-2100297054).
The `env-keys` function is deprecated in favor of [`env-sigs`](/pact-5/repl/env-sigs).
You should use `env-sigs` for setting transaction signer keys with associated capabilities.

### Basic syntax
Expand Down
2 changes: 1 addition & 1 deletion docs/builtins/SPV/verify-spv.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Use `verify-spv` to perform a platform-specific simplified payment verification (SPV) proof of a specified type for the specified payload.
The format of the payload object and the returned object depends on the type of proof you specify.
For information about payload types and return values, see platform-specific documentation.
For Chainweb nodes, see the [Chainweb API](/reference/chainweb-ref) specification.
For Chainweb nodes, see the [Chainweb API](/api/data-models) specification.

### Basic syntax

Expand Down
60 changes: 5 additions & 55 deletions docs/builtins/Time/format-time.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,59 +3,8 @@
Use `format-time` to format a `time` value using a specified `format`.
The `format-time` function is useful for converting time values to human-readable formats in Pact contracts.

The `parse-time` and `format-time` functions accept format codes that are derived from the formatting time `strftime` function time templates with some extensions.
You can use the following template specifiers that are introduced by using a single percentage (`%`) character to format time strings:

| Specifier | Description |
| :-------- | :---------- |
| `%a` | The abbreviated short name for the day of the week as specified for the current locale, for example,`"Sun"``"Sat"`. |
| `%A` | The full name for the day of the week as specified for the current locale, for example, `"Sunday"``"Saturday"`. |
| `%b` | The abbreviated month name as specified for the current locale, for example, `"Jan"``"Dec"`. |
| `%B` | The full month name as specified for the current locale, for example, `"January"``"December"`. |
| `%c` | The preferred calendar time representation as specified for the current locale, for example, `%a %b %e %H:%M:%S %Z %Y`.|
| `%C` | The century of the year with no padding.|
| `%d` | The day of the month as a decimal number zero-padded to two characters, for example, `"01"``"31"`.|
| `%D` | The date using the format `%m/%d/%y`.|
| `%e` | The day of the month as a decimal number space-padded to two characters, for example, `" 1"``"31"`.|
| `%f` | Century for the week date format with no padding.|
| `%F` | The date using the format `%Y-%m-%d` as specified in the ISO 8601 standard.|
| `%g` | The year corresponding to the ISO week number, without the century, zero-padded to two characters, for example, `"00"``"99"`.|
| `%G` | The year corresponding to the ISO week number with no padding.|
| `%h` | The abbreviated month name as specified for the current locale, for example, `"Jan"``"Dec"`. This format is the same as using the `%b` template.|
| `%H` | The hour of the day as a decimal number, using a 24-hour clock, zero-padded to two characters, for example, `"00"``"23"`.|
| `%I` | The hour of the day as a decimal number, using a 12-hour clock, zero-padded to two characters, for example, `"01"``"12"`.|
| `%j` | The day of the year as a decimal number, zero-padded to three characters, for example, `"001"``"366"`.|
| `%k` | The hour of the day as a decimal number, using a 24-hour clock, space-padded to two characters, for example, `" 0"``"23"`.|
| `%l` | The hour as a decimal number using a 12-hour clock, space-padded to two characters, for example, `" 1"``"12"`.|
| `%m` | The month of the year, zero-padded to two characters, for example, `"01"``"12"`.|
| `%M` | The minute of the hour, zero-padded to two characters, for example, `"00"``"59"`.|
| `%N` | Numeric representation of the time zone using the ISO 8601 standard, for example, `"-06:00"` or `"+01:00"`.|
| `%p` | The half of day representation of `"AM"` or `"PM"` or the corresponding strings specified for the current locale. Noon is treated as ‘PM’ and midnight as ‘AM’. If `"AM"` and `"PM"` aren't supported, the `%p` template returns an empty string.|
| `%P` | The half of day representation of `"AM"` or `"PM"` or the corresponding strings specified for the current locale, converted to lowercase, for example, `"am"` and `"pm"`. Noon is treated as ‘PM’ and midnight as ‘AM’. If `"am"` and `"pm"` aren't supported, the `%P` template returns an empty string.|
| `%Q` | The fraction of a second, up to six second decimal places, without trailing zeros. For a whole number of seconds, `%Q` produces an empty string.|
| `%r` | The complete calendar time including the AM/PM format as specified for the current locale, for example, `%I:%M:%S %p`.|
| `%R` | The hour and minute in decimal numbers using the format `%H:%M`.|
| `%s` | The number of whole seconds since the UNIX epoch (since 1970-01-01 00:00:00 UTC). For times before the UNIX epoch, this is a negative number. Note that in `%s.%q` and `%s%Q` formats, the decimals are positive, not negative. For example, 0.9 seconds before the UNIX epoch is formatted as `"-1.1"` with `%s%Q`.|
| `%S` | The seconds of a minute, zero-padded to two characters, for example, `"00"``"60"`.|
| `%T` | The time of day using the format `%H:%M:%S`.|
| `%u` | The day of the week as a number with Monday being 1, for example, `"1"``"7"`.|
| `%U` | The week number of the year as a number, starting with the first Sunday as the first day of the first week, zero-padded to two characters, for example, `"00"``"53"`.|
| `%v` | The microsecond of a second, zero-padded to six characters, for example, `"000000"``"999999"`.|
| `%V` | The week number as specified using the ISO 8601:1988 standard where weeks start with Monday and end with Sunday. zero-padded to two characters, for example,`"01"``"53"`.|
| `%w` | The day of the week as a number, starting with Sunday as 0, for example,`"0"` (= Sunday) – `"6"` (= Saturday).|
| `%W` | The week number of the year as a number (range 00 through 53), starting with the first Monday as the first day of the first week. zero-padded to two characters, for example, `"00"``"53"`.|
| `%x` | The preferred date representation as specified for the current `locale`, for example, `%m\/%d\/%y`.|
| `%X` | The preferred time of day representation as specified for the current locale, for example, `%H:%M:%S`.|
| `%y` | The year without a century as a number, zero-padded to two characters, for example, `"00"``"99"`.|
| `%Y` | The full year as a number with no padding.|
| `%z` | Numeric representation of the time zone using the RFC 822/ISO 8601:1988 standard, for example, `"-0600"` or `"+0100"`.|
| `%Z` | The time zone abbreviation or empty if the time zone can't be determined.|

Note that two percentage characters (`%%`) are interpretted as a literal percentage sign (`%`), not a time formatting template.
In addition, the template for picoseconds with zero padding (`%q`) doesn't work properly, so it's not included as a supported template for formatting time strings.

<!-- NEXT GEN DOCS
The following table provides a summary of common time formatting codes:
The `format-time` function accepts format codes that are derived from the formatting time `strftime` function time templates.
The following table provides a summary of the most common time formatting codes:

| Format | Purpose |
| --- | --- |
Expand All @@ -68,8 +17,9 @@ The following table provides a summary of common time formatting codes:

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).
-->
For information about all of the formats supported, see [Time formats](/pact-5/time/time-functions#time-formats).

Note that two percentage characters (`%%`) are interpreted as a literal percentage sign (`%`), not a time formatting template.

### Basic syntax

Expand Down
4 changes: 3 additions & 1 deletion docs/builtins/Time/hours.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ You can use this function in combination with the `add-time` function to add a s

The syntax for the `hours` function is as follows:

`(hours n)`
```pact
(hours n)
```

### Arguments

Expand Down
4 changes: 3 additions & 1 deletion docs/builtins/Time/minutes.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ You can use this function in combination with the `add-time` function to add a s

To represent a duration of N minutes, use the following syntax:

`(minutes n)`
```pact
(minutes n)
```

### Argument

Expand Down
64 changes: 8 additions & 56 deletions docs/builtins/Time/parse-time.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,59 +2,8 @@

Use `parse-time` to construct a UTC formatted time string from an input time that uses the specified format.

The `parse-time` and `format-time` functions accept format codes that are derived from the formatting time `strftime` function time templates with some extensions.
You can use the following template specifiers that are introduced by using a single percentage (`%`) character to format time strings:

| Specifier | Description |
| :-------- | :---------- |
| `%a` | The abbreviated short name for the day of the week as specified for the current locale, for example,`"Sun"``"Sat"`. |
| `%A` | The full name for the day of the week as specified for the current locale, for example, `"Sunday"``"Saturday"`. |
| `%b` | The abbreviated month name as specified for the current locale, for example, `"Jan"``"Dec"`. |
| `%B` | The full month name as specified for the current locale, for example, `"January"``"December"`. |
| `%c` | The preferred calendar time representation as specified for the current locale, for example, `%a %b %e %H:%M:%S %Z %Y`.|
| `%C` | The century of the year with no padding.|
| `%d` | The day of the month as a decimal number zero-padded to two characters, for example, `"01"``"31"`.|
| `%D` | The date using the format `%m/%d/%y`.|
| `%e` | The day of the month as a decimal number space-padded to two characters, for example, `" 1"``"31"`.|
| `%f` | Century for the week date format with no padding.|
| `%F` | The date using the format `%Y-%m-%d` as specified in the ISO 8601 standard.|
| `%g` | The year corresponding to the ISO week number, without the century, zero-padded to two characters, for example, `"00"``"99"`.|
| `%G` | The year corresponding to the ISO week number with no padding.|
| `%h` | The abbreviated month name as specified for the current locale, for example, `"Jan"``"Dec"`. This format is the same as using the `%b` template.|
| `%H` | The hour of the day as a decimal number, using a 24-hour clock, zero-padded to two characters, for example, `"00"``"23"`.|
| `%I` | The hour of the day as a decimal number, using a 12-hour clock, zero-padded to two characters, for example, `"01"``"12"`.|
| `%j` | The day of the year as a decimal number, zero-padded to three characters, for example, `"001"``"366"`.|
| `%k` | The hour of the day as a decimal number, using a 24-hour clock, space-padded to two characters, for example, `" 0"``"23"`.|
| `%l` | The hour as a decimal number using a 12-hour clock, space-padded to two characters, for example, `" 1"``"12"`.|
| `%m` | The month of the year, zero-padded to two characters, for example, `"01"``"12"`.|
| `%M` | The minute of the hour, zero-padded to two characters, for example, `"00"``"59"`.|
| `%N` | Numeric representation of the time zone using the ISO 8601 standard, for example, `"-06:00"` or `"+01:00"`.|
| `%p` | The half of day representation of `"AM"` or `"PM"` or the corresponding strings specified for the current locale. Noon is treated as ‘PM’ and midnight as ‘AM’. If `"AM"` and `"PM"` aren't supported, the `%p` template returns an empty string.|
| `%P` | The half of day representation of `"AM"` or `"PM"` or the corresponding strings specified for the current locale, converted to lowercase, for example, `"am"` and `"pm"`. Noon is treated as ‘PM’ and midnight as ‘AM’. If `"am"` and `"pm"` aren't supported, the `%P` template returns an empty string.|
| `%Q` | The fraction of a second, up to six second decimal places, without trailing zeros. For a whole number of seconds, `%Q` produces an empty string.|
| `%r` | The complete calendar time including the AM/PM format as specified for the current locale, for example, `%I:%M:%S %p`.|
| `%R` | The hour and minute in decimal numbers using the format `%H:%M`.|
| `%s` | The number of whole seconds since the UNIX epoch (since 1970-01-01 00:00:00 UTC). For times before the UNIX epoch, this is a negative number. Note that in `%s.%q` and `%s%Q` formats, the decimals are positive, not negative. For example, 0.9 seconds before the UNIX epoch is formatted as `"-1.1"` with `%s%Q`.|
| `%S` | The seconds of a minute, zero-padded to two characters, for example, `"00"``"60"`.|
| `%T` | The time of day using the format `%H:%M:%S`.|
| `%u` | The day of the week as a number with Monday being 1, for example, `"1"``"7"`.|
| `%U` | The week number of the year as a number, starting with the first Sunday as the first day of the first week, zero-padded to two characters, for example, `"00"``"53"`.|
| `%v` | The microsecond of a second, zero-padded to six characters, for example, `"000000"``"999999"`.|
| `%V` | The week number as specified using the ISO 8601:1988 standard where weeks start with Monday and end with Sunday. zero-padded to two characters, for example,`"01"``"53"`.|
| `%w` | The day of the week as a number, starting with Sunday as 0, for example,`"0"` (= Sunday) – `"6"` (= Saturday).|
| `%W` | The week number of the year as a number (range 00 through 53), starting with the first Monday as the first day of the first week. zero-padded to two characters, for example, `"00"``"53"`.|
| `%x` | The preferred date representation as specified for the current `locale`, for example, `%m\/%d\/%y`.|
| `%X` | The preferred time of day representation as specified for the current locale, for example, `%H:%M:%S`.|
| `%y` | The year without a century as a number, zero-padded to two characters, for example, `"00"``"99"`.|
| `%Y` | The full year as a number with no padding.|
| `%z` | Numeric representation of the time zone using the RFC 822/ISO 8601:1988 standard, for example, `"-0600"` or `"+0100"`.|
| `%Z` | The time zone abbreviation or empty if the time zone can't be determined.|

Note that two percentage characters (`%%`) are interpreted as a literal percentage sign (`%`), not a time formatting template.
In addition, the template for picoseconds with zero padding (`%q`) doesn't work properly, so it's not included as a supported template for formatting time strings.

<!-- NEXT GEN DOCS
The following table provides a summary of common time formatting codes:
The `parse-time` function accepts format codes that are derived from the formatting time `strftime` function time templates.
The following table provides a summary of the most common time formatting codes:

| Format | Purpose |
| --- | --- |
Expand All @@ -65,14 +14,17 @@ The following table provides a summary of common time formatting codes:
| %M | Minute of of the hour, zero-padded to two characters, "00"–"59" |
| %S | Second of the minute, zero-padded to two characters, "00"–"60" |

For more information about time formats and specifiers, see [Time formats](/pact-5/Time/time-functions#time-formats).
-->
For more information about time formats and specifiers, see [Time formats](/pact-5/time/time-functions#time-formats).

Note that two percentage characters (`%%`) are interpreted as a literal percentage sign (`%`), not a time formatting template.

### Basic syntax

To construct a UTC time string from a input time that uses a specified format, use the following syntax:

`(parse-time format input)`
```pact
(parse-time format input)
```

### Arguments

Expand Down

0 comments on commit d7d8567

Please sign in to comment.