-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create new timer linked to a capture #15
Comments
Currently looking on how to convert a NaiveDateTime from Elixir to an Elm time type So when a timer is created the api is returning a stringify json object similar to: {"data":{"capture_id":3,"started_at":"2020-03-11T14:54:15","stopped_at":null,"timer_id":3}} The current type to represent the timer in Elm: type alias Timer =
{ startedAt : String
, stoppedAt : Maybe String
} decoder when receiving the json: timerDecoder : JD.Decoder Timer
timerDecoder =
JD.field "data"
(JD.map2 Timer
(JD.field "started_at" JD.string)
(JD.maybe (JD.field "stoped_at" JD.string))
) reviewing how time works with Elm:https://guide.elm-lang.org/effects/time.html |
I've spent a bit of time looking at how to convert the time from Elixir to Elm import Iso8601
Iso8601.toTime "2020-03-11T14:54:15"
Ok (Posix 1583938455000)
: Result (List Parser.DeadEnd) Time.Posix |
The status of a capture will depend on the timers linked to it. type alias Capture =
{ idCapture : Int
, text : String
, completed : Bool
, disabled : Bool
} to type alias Capture =
{ idCapture : Int
, text : String
, status: CaptureStatus
} where type CaptureStatus =
ToDo -- when created
| Completed -- when completed value is true in Postgres
| InProgress -- when the most recent timer is running, ie the `stoppedAt` value is null
| Disabled -- when waiting for a response from the api. This disable the button to avoid wrong state
| Error String -- represent errors, e.g capture can't be saved, not authorized, multiple timers running at the same time... I'm also thinking of creating a specific module for the Capture. This should make the capture page more readable |
Updating the
The elm-iso8601 package provides a decoder to convert a string value to a posix. |
linked to dwyl/app#265
|
The text was updated successfully, but these errors were encountered: