3{-| Library for working with time.
6@docs Time, millisecond, second, minute, hour,
7 inMilliseconds, inSeconds, inMinutes, inHours
10@docs fps, fpsWhen, every
13@docs timestamp, delay, since
21{-| Type alias to make it clearer when you are working with time values.
22Using the `Time` constants instead of raw numbers is very highly recommended.
26{-| Units of time, making it easier to specify things like a half-second
27`(500 * milliseconds)` without remembering Elm’s underlying units of time.
33second = 1000 * millisecond
41inMilliseconds : Time -> Float
44inSeconds : Time -> Float
45inSeconds t = t / second
47inMinutes : Time -> Float
48inMinutes t = t / minute
50inHours : Time -> Float
53{-| Takes desired number of frames per second (fps). The resulting signal
54gives a sequence of time deltas as quickly as possible until it reaches
55the desired FPS. A time delta is the time between the last frame and the
58fps : number -> Signal Time
61{-| Same as the fps function, but you can turn it on and off. Allows you
62to do brief animations based on user input without major inefficiencies.
63The first time delta after a pause is always zero, no matter how long
64the pause was. This way summing the deltas will actually give the amount
65of time that the output signal has been running.
67fpsWhen : number -> Signal Bool -> Signal Time
68fpsWhen = Native.Time.fpsWhen
70{-| Takes a time interval t. The resulting signal is the current time, updated
73every : Time -> Signal Time
74every = Native.Time.every
76{-| Takes a time `t` and any signal. The resulting boolean signal is true for
77time `t` after every event on the input signal. So ``(second `since`
78Mouse.clicks)`` would result in a signal that is true for one second after
79each mouse click and false otherwise.
81since : Time -> Signal a -> Signal Bool
82since = Native.Time.since
84{-| Add a timestamp to any signal. Timestamps increase monotonically. When you
85create `(timestamp Mouse.x)`, an initial timestamp is produced. The timestamp
86updates whenever `Mouse.x` updates.
88Timestamp updates are tied to individual events, so
89`(timestamp Mouse.x)` and `(timestamp Mouse.y)` will always have the same
90timestamp because they rely on the same underlying event (`Mouse.position`).
92timestamp : Signal a -> Signal (Time, a)
93timestamp = Native.Time.timestamp
95{-| Delay a signal by a certain amount of time. So `(delay second Mouse.clicks)`
96will update one second later than any mouse click.
98delay : Time -> Signal a -> Signal a
99delay = Native.Time.delay
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list