class Time

class Time

lib/time.tya:2

Time provides the time/Time standard library API.

Source
# Time provides the time/Time standard library API.
class Time
  # Time.value stores instance state.
  # @type Nil
  value: nil

  # Time.initialize stores a time value or parseable text.
  # @param value String value value.
  # @return Self the initialized object.
  initialize: value = nil ->
    self.value = value

  # Time.duration constructs a duration value.
  # @param seconds Any seconds value.
  # @param options Dict options value.
  # @return Any the resulting value.
  duration: seconds = 0, options = {} ->
    time_duration(seconds, options)

  # Time.format provides the time/Time standard library operation.
  # @param t Any t value.
  # @param layout Any layout value.
  # @return Any the resulting value.
  format: t, layout = nil ->
    if layout == nil
      layout = t
      t = self.value
    time_format(t, layout)

  # Time.monotonic returns a monotonic timestamp.
  # @return Any the resulting value.
  monotonic: -> time_monotonic()

  # Time.now provides the time/Time standard library operation.
  # @return Any the resulting value.
  now: -> time_now()

  # Time.parse provides the time/Time standard library operation.
  # @param text String text value.
  # @param layout Any layout value.
  # @return Any the resulting value.
  parse: text = nil, layout = "rfc3339" ->
    if self.value != nil
      if text != nil
        if layout == "rfc3339"
          layout = text
          text = self.value
        if layout == nil
          layout = text
          text = self.value
    if text == nil
      text = self.value
    time_parse(text, layout)

  # Time.since provides the time/Time standard library operation.
  # @param t Any t value.
  # @return Any the resulting value.
  since: t = nil ->
    if t == nil
      t = self.value
    time_since(t)

  # Time.sleep provides the time/Time standard library operation.
  # @param duration_or_seconds Any duration or seconds value.
  # @return Nil the resulting value.
  sleep: duration_or_seconds ->
    time_sleep(duration_or_seconds)

  # Time.unix constructs a UTC wall-clock time.
  # @param seconds Any seconds value.
  # @param nanos Any nanos value.
  # @return Any the resulting value.
  unix: seconds, nanos = 0 ->
    time_unix(seconds, nanos)

Instance Variables

value

Time.value

lib/time.tya:5

Time.value stores instance state.

Source
  # Time.value stores instance state.
  # @type Nil
  value: nil

Methods

duration

Time.duration(seconds = 0, options = {})

lib/time.tya:17

Time.duration constructs a duration value.

Source
  # Time.duration constructs a duration value.
  # @param seconds Any seconds value.
  # @param options Dict options value.
  # @return Any the resulting value.
  duration: seconds = 0, options = {} ->
    time_duration(seconds, options)

format

Time.format(t, layout = nil)

lib/time.tya:24

Time.format provides the time/Time standard library operation.

Source
  # Time.format provides the time/Time standard library operation.
  # @param t Any t value.
  # @param layout Any layout value.
  # @return Any the resulting value.
  format: t, layout = nil ->
    if layout == nil
      layout = t
      t = self.value
    time_format(t, layout)

initialize

Time.initialize(value = nil)

lib/time.tya:10

Time.initialize stores a time value or parseable text.

Source
  # Time.initialize stores a time value or parseable text.
  # @param value String value value.
  # @return Self the initialized object.
  initialize: value = nil ->
    self.value = value

monotonic

Time.monotonic()

lib/time.tya:32

Time.monotonic returns a monotonic timestamp.

Source
  # Time.monotonic returns a monotonic timestamp.
  # @return Any the resulting value.
  monotonic: -> time_monotonic()

now

Time.now()

lib/time.tya:36

Time.now provides the time/Time standard library operation.

Source
  # Time.now provides the time/Time standard library operation.
  # @return Any the resulting value.
  now: -> time_now()

parse

Time.parse(text = nil, layout = "rfc3339")

lib/time.tya:42

Time.parse provides the time/Time standard library operation.

Source
  # Time.parse provides the time/Time standard library operation.
  # @param text String text value.
  # @param layout Any layout value.
  # @return Any the resulting value.
  parse: text = nil, layout = "rfc3339" ->
    if self.value != nil
      if text != nil
        if layout == "rfc3339"
          layout = text
          text = self.value
        if layout == nil
          layout = text
          text = self.value
    if text == nil
      text = self.value
    time_parse(text, layout)

since

Time.since(t = nil)

lib/time.tya:58

Time.since provides the time/Time standard library operation.

Source
  # Time.since provides the time/Time standard library operation.
  # @param t Any t value.
  # @return Any the resulting value.
  since: t = nil ->
    if t == nil
      t = self.value
    time_since(t)

sleep

Time.sleep(duration_or_seconds)

lib/time.tya:66

Time.sleep provides the time/Time standard library operation.

Source
  # Time.sleep provides the time/Time standard library operation.
  # @param duration_or_seconds Any duration or seconds value.
  # @return Nil the resulting value.
  sleep: duration_or_seconds ->
    time_sleep(duration_or_seconds)

unix

Time.unix(seconds, nanos = 0)

lib/time.tya:73

Time.unix constructs a UTC wall-clock time.

Source
  # Time.unix constructs a UTC wall-clock time.
  # @param seconds Any seconds value.
  # @param nanos Any nanos value.
  # @return Any the resulting value.
  unix: seconds, nanos = 0 ->
    time_unix(seconds, nanos)