For the complete documentation index, see llms.txt. This page is also available as Markdown.

Timestamp

To try it out today, please contact us at support@vgs.io

Working with Timestamp

Larky (unlike Python) does not have built-in time() method, as there are certain reasons for that. However, there is a solution that provides a possibility of getting the current timestamp with the help of FCO (First Class Operations) and using this value directly in Larky code.

Larky code sample

There is an example of code below that reads the imestamp value from the ctx storage and writes the result into the message body.

The snippet below contains tags from the YAML in order to show how to:

  • Place the piece of configuration properly in your YAML

  • Combine FCO and Larky together in one route filter

operations:
  - name: github.com/verygoodsecurity/common/utils/date-time/Now
    parameters:
      var: ctx.timestamp
  - name: github.com/verygoodsecurity/common/compute/larky/http/Process
    parameters:
      script: |-
        load("@stdlib//json","json")
        load("@stdlib//builtins", builtins="builtins")

        def process(input, ctx):
          body = {}
          body['timestamp'] = ctx['timestamp']
          input.body = builtins.bytes(json.dumps(body))
          return input

Testing

Request to send:

Response example:

Last updated