Skip to content

Instantly share code, notes, and snippets.

@udoschneider
Created November 8, 2015 11:31
Show Gist options
  • Save udoschneider/116382a58e23ebd1b6f2 to your computer and use it in GitHub Desktop.
Save udoschneider/116382a58e23ebd1b6f2 to your computer and use it in GitHub Desktop.
"https://flow.polar.com/activity/data/1.6.2015/6.12.2015"
json := Clipboard clipboardText.
data := NeoJSONReader on: json readStream.
data := data next at: 'data'.
sleep := Dictionary new.
data reverse collect: [:each |
|summary sleepTime |
summary := (each at: 'summaries') at: 1.
ts := (DateAndTime fromString: (summary at: 'datetime')) asDate.
sleepTime := ((((summary at: 'sleepTime') / 1000 / 60 / 60) asFloat * 10) rounded / 10) asFloat.
ts -> sleepTime
].
sleep.
(Date year: 2001 month: 1 day: 1) + (388736855 / (24 * 60 * 60)) days
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment