avh4 / avh4/elm-program-test

getting the current simulated time

Open
#105 2 comments 0 reactions 0 assignees View on GitHub
discussion
Dominant language
Elm
Stars
95
Forks
28
PR merge metrics
No merged PRs in 30d

Description

I'm writing a program that needs to get the current time pretty often (it uses it to timestamp a [hybrid logical clock](https://cse.buffalo.edu/tech-reports/2014-04.pdf).)

Right now I can set delays, but I don't have a way to get the current time afterwards. My for-real `Effect -> Msg` handles it like this:

```elm
SaveAfter delay ->
Process.sleep delay
|> Task.andThen (\_ -> Time.now)
|> Task.perform Save
```

I see that I can advance time with `advanceTime`, but I'd love to be able to get at that counter in a simulated task!

Contributor guide

Open the contributing guide

Research direction

Start by tracing how advanceTime updates simulated time and how simulated tasks handle Process.sleep. Compare that path with the Time.now call in the SaveAfter example. Done means a simulated task can read the current simulated time after time has been advanced, with behavior covered by the relevant tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
elm
Domain
testing
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.