diff --git a/frontend/apps/reader/modules/readerfooter.lua b/frontend/apps/reader/modules/readerfooter.lua index 5e35c00c9..04022da6b 100644 --- a/frontend/apps/reader/modules/readerfooter.lua +++ b/frontend/apps/reader/modules/readerfooter.lua @@ -177,7 +177,7 @@ local footerTextGeneratorMap = { time = function(footer) local symbol_type = footer.settings.item_prefix or "icons" local prefix = symbol_prefix[symbol_type].time - local clock = util.secondsToHour(os.time(), footer.settings.time_format == "12") + local clock = util.secondsToHour(os.time(), G_reader_settings:isTrue("twelve_hour_clock")) if not prefix then return clock else @@ -1287,43 +1287,6 @@ function ReaderFooter:addToMainMenu(menu_items) }, }, }, - { - text = _("Time format"), - sub_item_table = { - { - text_func = function() - local footer = {} - footer.settings = {} - footer.settings.time_format = "24" - footer.settings.item_prefix = self.settings.item_prefix or "icons" - return T(_("24-hour (%1)"),footerTextGeneratorMap.time(footer)) - end, - checked_func = function() - return self.settings.time_format == "24" or self.settings.time_format == nil - end, - callback = function() - self.settings.time_format = "24" - self:refreshFooter(true) - end, - }, - { - text_func = function() - local footer = {} - footer.settings = {} - footer.settings.time_format = "12" - footer.settings.item_prefix = self.settings.item_prefix or "icons" - return T(_("12-hour (%1)"),footerTextGeneratorMap.time(footer)) - end, - checked_func = function() - return self.settings.time_format == "12" - end, - callback = function() - self.settings.time_format = "12" - self:refreshFooter(true) - end, - }, - } - }, { text = _("Duration format"), sub_item_table = { diff --git a/frontend/readhistory.lua b/frontend/readhistory.lua index e2405b60c..4d70278ec 100644 --- a/frontend/readhistory.lua +++ b/frontend/readhistory.lua @@ -37,7 +37,7 @@ local function buildEntry(input_time, input_file) -- we fallback to it no sidecar file) last_read_ts = DocSettings:getLastSaveTime(file_path) or input_time end - return util.secondsToDate(last_read_ts, G_reader_settings:nilOrTrue("twelve_hour_clock")) + return util.secondsToDate(last_read_ts, G_reader_settings:isTrue("twelve_hour_clock")) end, callback = function() local ReaderUI = require("apps/reader/readerui") diff --git a/frontend/ui/elements/common_settings_menu_table.lua b/frontend/ui/elements/common_settings_menu_table.lua index 4819b1cbd..6a96504d0 100644 --- a/frontend/ui/elements/common_settings_menu_table.lua +++ b/frontend/ui/elements/common_settings_menu_table.lua @@ -77,10 +77,10 @@ common_settings.time = { text = _("12-hour clock"), keep_menu_open = true, checked_func = function() - return G_reader_settings:nilOrTrue("twelve_hour_clock") + return G_reader_settings:isTrue("twelve_hour_clock") end, callback = function() - G_reader_settings:flipNilOrTrue("twelve_hour_clock") + G_reader_settings:flipNilOrFalse("twelve_hour_clock") end, } } diff --git a/frontend/ui/widget/touchmenu.lua b/frontend/ui/widget/touchmenu.lua index fea07082c..e0a08e62e 100644 --- a/frontend/ui/widget/touchmenu.lua +++ b/frontend/ui/widget/touchmenu.lua @@ -640,7 +640,7 @@ function TouchMenu:updateItems() self.page_info_left_chev:enableDisable(self.page > 1) self.page_info_right_chev:enableDisable(self.page < self.page_num) - local time_info_txt = util.secondsToHour(os.time(), G_reader_settings:nilOrTrue("twelve_hour_clock")) + local time_info_txt = util.secondsToHour(os.time(), G_reader_settings:isTrue("twelve_hour_clock")) local powerd = Device:getPowerDevice() local batt_lvl = powerd:getCapacity() local batt_symbol diff --git a/frontend/up_reg.list b/frontend/up_reg.list deleted file mode 100644 index 77fddaf52..000000000 --- a/frontend/up_reg.list +++ /dev/null @@ -1,19 +0,0 @@ -./apps/reader/modules/readerfooter.lua: UIManager.update_regions_func = function() -./apps/reader/modules/readerhighlight.lua: UIManager.update_regions_func = function() -./ui/widget/button.lua: UIManager.update_regions_func = function() -./ui/widget/iconbutton.lua: UIManager.update_regions_func = function() -./ui/widget/dictquicklookup.lua: UIManager.update_regions_func = function() -./ui/widget/scrolltextwidget.lua: UIManager.update_regions_func = function() -./ui/widget/touchmenu.lua: UIManager.update_regions_func = function() -./ui/widget/touchmenu.lua: UIManager.update_regions_func = function() -./ui/widget/virtualkeyboard.lua: UIManager.update_regions_func = function() -./ui/widget/virtualkeyboard.lua: UIManager.update_regions_func = function() -./ui/widget/virtualkeyboard.lua: UIManager.update_regions_func = nil -./ui/widget/toggleswitch.lua: UIManager.update_regions_func = function() -./ui/widget/configdialog.lua: UIManager.update_regions_func = function() -./ui/widget/configdialog.lua: UIManager.update_regions_func = function() -./ui/uimanager.lua: update_regions_func = nil, -./ui/uimanager.lua: if self.update_regions_func then -./ui/uimanager.lua: local update_regions = self.update_regions_func() -./ui/uimanager.lua: for _, update_region in ipairs(update_regions) do -./ui/uimanager.lua: self.update_regions_func = nil diff --git a/frontend/util.lua b/frontend/util.lua index 0509b5d9c..dbda666f6 100644 --- a/frontend/util.lua +++ b/frontend/util.lua @@ -224,21 +224,40 @@ end ---- @int seconds number of seconds ---- @bool twelve_hour_clock ---- @treturn string hour string -function util.secondsToHour(seconds, twelve_hour_clock) - local time - if twelve_hour_clock then - if os.date("%p", seconds) == "AM" then - -- @translators This is the time in the morning in the 12-hour clock (%I is the hour, %M the minute). - time = os.date(_("%I:%M AM"), seconds) +--- @note: The MS CRT doesn't support either %l & %k, or the - format modifier (as they're not technically C99 or POSIX). +--- They are otherwise supported on Linux, BSD & Bionic, so, just special-case Windows... +--- We *could* arguably feed the os.date output to gsub("^0(%d)(.*)$", "%1%2"), but, while unlikely, +--- it's conceivable that a translator would put something other that the hour at the front of the string ;). +if jit.os == "Windows" then + function util.secondsToHour(seconds, twelve_hour_clock) + if twelve_hour_clock then + if os.date("%p", seconds) == "AM" then + -- @translators This is the time in the morning using a 12-hour clock (%I is the hour, %M the minute). + return os.date(_("%I:%M AM"), seconds) + else + -- @translators This is the time in the afternoon using a 12-hour clock (%I is the hour, %M the minute). + return os.date(_("%I:%M PM"), seconds) + end else - -- @translators This is the time in the afternoon in the 12-hour clock (%I is the hour, %M the minute). - time = os.date(_("%I:%M PM"), seconds) + -- @translators This is the time using a 24-hour clock (%H is the hour, %M the minute). + return os.date(_("%H:%M"), seconds) + end + end +else + function util.secondsToHour(seconds, twelve_hour_clock) + if twelve_hour_clock then + if os.date("%p", seconds) == "AM" then + -- @translators This is the time in the morning using a 12-hour clock (%-I is the hour, %M the minute). + return os.date(_("%-I:%M AM"), seconds) + else + -- @translators This is the time in the afternoon using a 12-hour clock (%-I is the hour, %M the minute). + return os.date(_("%-I:%M PM"), seconds) + end + else + -- @translators This is the time using a 24-hour clock (%-H is the hour, %M the minute). + return os.date(_("%-H:%M"), seconds) end - else - -- @translators This is the time in the 24-hour clock (%H is the hour, %M the minute). - time = os.date(_("%H:%M"), seconds) end - return time end --- Converts timestamp to a date string