Login About Gallery
Last Night's Sleep - Start Of Sleep
COMMENT
‎Made by: mvan231 Modified by mvan231 ~~~~~For~~~~~ Post: How to find sleep time and wake up time By: WheretheEoopy Link: https://www.reddit.com/r/shortcuts/comments/18b4xlb/how_to_find_sleep_time_and_wake_up_time/ ~~~~~~~~~~ Originally created before advanced sleep tracking was available in WatchOS 9 / iOS 16. Updated in 2022 for the inclusion of these sleep stages Updates for showing Hours and Minutes of total sleep time vs x.y hours V4 - Updated calculation method to use seconds instead of relying on the sum method - Handling added for when detailed sleep data isn't available
CALENDAR
‎Subtract ‎1 ‎days ‎from ‎Current Date
DATE
‎Specified Date ‎Adjusted Date ‎ 18:00
TEXT
‎{ "In Bed":[], "Core":[], "REM":[], "Deep":[], "Awake":[] }
VARIABLES
‎Set variable ‎Dict ‎to ‎Text
HEALTH
‎Find ‎All Health Samples ‎where
‎All the following are true
‎[{'class': 'filter-property', 'value': 'Type'}, {'class': 'filter-operator', 'value': 'is'}, {'class': 'filter-benchmark', 'value': 'Sleep'}]
‎[{'class': 'filter-property', 'value': 'Start Date'}, {'class': 'filter-operator', 'value': 'is in the last'}, {'class': 'filter-benchmark', 'value': '1', 'glyph': '', 'UUID': ''}, {'class': 'filter-unit', 'value': 'day', 'glyph': '', 'UUID': ''}]
Sort by
‎Start Date
Order
‎Oldest First
Limit
SCRIPTING
‎Repeat with each item in ‎Health Samples
NOTHING
‎Nothing
SCRIPTING
‎If ‎Date ‎is less than ‎Repeat Item
SCRIPTING
‎Get ‎Value ‎for ‎Repeat Item ‎in ‎Dict
CALENDAR
‎Get time between ‎Repeat Item ‎and ‎Repeat Item ‎in ‎Seconds
LIST
SCRIPTING
‎Set ‎Repeat Item ‎to ‎List ‎in ‎Dictionary
VARIABLES
‎Set variable ‎Dict ‎to ‎Dictionary
VARIABLES
‎Get ‎Repeat Item
SCRIPTING
‎End If
SCRIPTING
‎End Repeat
SCRIPTING
‎Get ‎First Item ‎from ‎Repeat Results
TEXT
‎Item from List
DOCUMENTS
‎Show ‎Text ‎in Quick Look

Showcuts

Magic Vars

Screenshot

Submitted Anonymously 8 months ago

This is an old shortcut, so some variables might be missing!

Visit iCloud (iOS)

Copy iCloud Link

Scan QR Code

0