Time()

Convert a time String to an ISO-8601 time value Time value.

Signature

Time(timeString: String): Time

Description

The Time() method converts an ISO-8601 timeString to a Time value.

Parameter fields:

Time field Description

yyyy

Four-digit year.

MM

Month, from 01 to 12.

dd

Day, from 01 to 31.

T

Date and time separator.

hh

Hours, from 00 to 23.

mm

Minutes, from 00 to 59.

ss

Seconds, from 00 to 59, which can also be expressed as a decimal fraction to give nanosecond resolution.

TZO

Timezone offset from UTC which can be one of:

Timezone Description

Z

UTC, no offset

+hhmm

Positive hour and minute offset from UTC.

-hhmm

Negative hour and minute offset from UTC.

This method is equivalent to the Time.fromString() method.

Parameters

Parameter Type Required Description

timeString

String

Yes

Time String in the form yyyy-MM-ddThh:mm:ssTZO.

Return value

Type Description

Time

ISO-8601 time value object representing timeString.

Examples

Convert a time String to a Time value:

Time("2099-10-20T21:15:09.890729Z")
Time("2099-10-20T21:15:09.890729Z")

Test if a document timestamp is equal to a given time:

Customer.where(.ts == Time("2099-06-25T20:23:49.070Z"))
{
  data: [
    {
      id: "401697070367375437",
      coll: Customer,
      ts: Time("2099-06-25T20:23:49.070Z"),
      firstName: "Alice",
      lastName: "Appleseed",
      email: "alice.appleseed@example.com",
      address: {
        street: "87856 Mendota Court",
        city: "Washington",
        state: "DC",
        zipCode: "20220"
      },
      telephone: "208-346-0715",
      creditCard: {
        network: "Visa",
        number: "4556781272473393"
      }
    },
    ...
  ]
}

Is this article helpful? 

Tell Fauna how the article can be improved:
Visit Fauna's forums or email docs@fauna.com

Thank you for your feedback!