Module datetime
This module contains date translations and helper functions for the KOReader frontend.
Functions
secondsToClock (seconds, withoutSeconds) | Converts seconds to a clock string. |
secondsToHClock (seconds, withoutSeconds, hmsFormat, withDays) | Converts seconds to a period of time string. |
secondsToClockDuration (Either, withoutSeconds, hmsFormat, withDays, compact) | Converts seconds to a clock type (classic or modern), based on the given format preference "Classic" format calls secondsToClock, and "Modern" format calls secondsToHClock |
secondsToHour (seconds, twelve_hour_clock) | Converts timestamp to an hour string |
secondsToDate (seconds) | Converts timestamp to a date string |
secondsToDateTime (seconds, twelve_hour_clock) | Converts timestamp to a date+time string |
Functions
- secondsToClock (seconds, withoutSeconds)
-
Converts seconds to a clock string.
Source: https://gist.github.com/jesseadams/791673
Parameters:
- seconds int number of seconds
- withoutSeconds bool if true 00:00, if false 00:00:00
Returns:
-
string
clock string in the form of 00:00 or 00:00:00
- secondsToHClock (seconds, withoutSeconds, hmsFormat, withDays)
-
Converts seconds to a period of time string.
Parameters:
- seconds int number of seconds
- withoutSeconds bool if true 1h30', if false 1h30'10"
- hmsFormat bool , if true format 1h30m10s
- withDays bool , if true format 1d12h30m10s
Returns:
-
string
clock string in the form of 1h30'10" or 1h30m10s
- secondsToClockDuration (Either, withoutSeconds, hmsFormat, withDays, compact)
-
Converts seconds to a clock type (classic or modern), based on the given format preference
"Classic" format calls secondsToClock, and "Modern" format calls secondsToHClock
Parameters:
- Either string "modern" for 1h30'10" or "classic" for 1:30:10
- withoutSeconds bool if true 1h30' or 1h30m, if false 1h30'10" or 1h30m10s
- hmsFormat bool , modern format only, if true format 1h30m or 1h30m10s
- withDays bool , if hours>=24 include days in clock string 1d12h10m10s
- compact bool , if set removes all leading zeros (incl. units if necessary)
Returns:
-
string
clock string in the specific format of 1h30', 1h30'10" resp. 1h30m, 1h30m10s
- secondsToHour (seconds, twelve_hour_clock)
-
Converts timestamp to an hour string
Parameters:
- seconds int number of seconds
- twelve_hour_clock bool
Returns:
-
string
hour string
- secondsToDate (seconds)
-
Converts timestamp to a date string
Parameters:
- seconds int number of seconds
Returns:
-
string
date string
- secondsToDateTime (seconds, twelve_hour_clock)
-
Converts timestamp to a date+time string
Parameters:
- seconds int number of seconds
- twelve_hour_clock bool
Returns:
-
string
date+time