Time - script API

StackState Self-hosted v5.1.x

Time API offers helper functions to manipulate with time type in StackState scripts.

Function: Time.currentTimeSlice()

Returns a time slice for the current timestamp

Examples

Time.currentTimeSlice().then { slice -> 
    Topology.query('environments in ("Production")')
    .at(slice)
    .components()
    .thenCollect { component -> 
       Component
       .withId(component.id)
       .at(slice)
       .get()
    } 
}

Function: Time.format(instant: Instant, pattern: String)

Format an instant to string using the given formatting pattern

Args

Examples

Format an instant to ISO 8601 time

Time.format(1577966400000, "yyyy-MM-dd'T'HH:mm:ss'Z'")

Function: Time.epochMs(instant: Instant)

Args

Examples

Convert a string timestamp to epoch

Time.epochMs("2011-12-03T10:15:30Z")

Last updated