A collection of plugins to calculate time based data. Developed for My Morning Routine - Interview Statistics, available for anyone.
Copy the .rb
plugin files into the /_plugins/
directory of your Jekyll project.
Convert any time (12h/24h) to seconds for further calculations.
{{ '11:00PM' | time_seconds }}
=> 82800
Convert seconds to any time format for the final output.
{{ 82800 | seconds_time }}
=> 11:00PM
Calculate the time difference of two time values.
{{ '9:00AM' | time_diff:'11:30AM' }}
=> 2:30h
You can also mix time formats.
{{ '2:00PM' | time_diff:'18:00' }}
=> 4:00h
Note: Switch to a date object, if you’d like to calculate differences of over 24 hours.
As always, you can use multiple Liquid filters at once. They are applied from left to right.
{% assign sleep_seconds = post.data.wakeup | time_diff:post.data.bedtime | time_seconds %}