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

Function: Time.epochMs(instant: Instant)

Args

Examples

Convert a string timestamp to epoch

Last updated