@ -1476,9 +1476,9 @@ function ReaderStatistics:getCurrentStat()
local estimate_end_of_read_date = datetime.secondsToDate ( tonumber ( now_ts + estimate_days_to_read * 86400 ) , true )
local estimate_end_of_read_date = datetime.secondsToDate ( tonumber ( now_ts + estimate_days_to_read * 86400 ) , true )
local estimates_valid = time_to_read > 0 -- above values could be 'nan' and 'nil'
local estimates_valid = time_to_read > 0 -- above values could be 'nan' and 'nil'
local user_duration_format = G_reader_settings : readSetting ( " duration_format " , " classic " )
local user_duration_format = G_reader_settings : readSetting ( " duration_format " , " classic " )
local avg_page_time_string = datetime.secondsToClockDuration ( user_duration_format , self.avg_time , false , true )
local avg_page_time_string = datetime.secondsToClockDuration ( user_duration_format , self.avg_time , false )
local avg_day_time_string = datetime.secondsToClockDuration ( user_duration_format , book_read_time / tonumber ( total_days ) , false , true )
local avg_day_time_string = datetime.secondsToClockDuration ( user_duration_format , book_read_time / tonumber ( total_days ) , false )
local time_to_read_string = estimates_valid and datetime.secondsToClockDuration ( user_duration_format , time_to_read , false , true ) or _ ( " N/A " )
local time_to_read_string = estimates_valid and datetime.secondsToClockDuration ( user_duration_format , time_to_read , false ) or _ ( " N/A " )
-- Use more_arrow to indicate that an option shows another view
-- Use more_arrow to indicate that an option shows another view
-- Use " ⓘ" to indicate that an option will show an info message
-- Use " ⓘ" to indicate that an option will show an info message
@ -1497,11 +1497,11 @@ function ReaderStatistics:getCurrentStat()
-- Global statistics (may consider other books than current book)
-- Global statistics (may consider other books than current book)
-- Since last resume
-- Since last resume
{ _ ( " Time spent reading this session " ) , datetime.secondsToClockDuration ( user_duration_format , current_duration , false , true ) } ,
{ _ ( " Time spent reading this session " ) , datetime.secondsToClockDuration ( user_duration_format , current_duration , false ) } ,
{ _ ( " Pages read this session " ) , tonumber ( current_pages ) , separator = true } ,
{ _ ( " Pages read this session " ) , tonumber ( current_pages ) , separator = true } ,
-- Today
-- Today
{ _ ( " Time spent reading today " ) .. " " .. more_arrow , datetime.secondsToClockDuration ( user_duration_format , today_duration , false , true ),
{ _ ( " Time spent reading today " ) .. " " .. more_arrow , datetime.secondsToClockDuration ( user_duration_format , today_duration , false ),
callback = function ( )
callback = function ( )
local CalendarView = require ( " calendarview " )
local CalendarView = require ( " calendarview " )
local title_callback = function ( this )
local title_callback = function ( this )
@ -1515,9 +1515,9 @@ function ReaderStatistics:getCurrentStat()
-- Current book statistics (includes re-reads)
-- Current book statistics (includes re-reads)
-- Time-focused book stats
-- Time-focused book stats
{ _ ( " Total time spent on this book " ) , datetime.secondsToClockDuration ( user_duration_format , total_time_book , false , true ) } ,
{ _ ( " Total time spent on this book " ) , datetime.secondsToClockDuration ( user_duration_format , total_time_book , false ) } ,
-- capped to self.settings.max_sec per distinct page
-- capped to self.settings.max_sec per distinct page
{ _ ( " Time spent reading " ) , datetime.secondsToClockDuration ( user_duration_format , book_read_time , false , true ) } ,
{ _ ( " Time spent reading " ) , datetime.secondsToClockDuration ( user_duration_format , book_read_time , false ) } ,
-- estimation, from current page to end of book
-- estimation, from current page to end of book
{ _ ( " Estimated reading time left " ) .. " ⓘ " , time_to_read_string , callback = estimated_popup , separator = true } ,
{ _ ( " Estimated reading time left " ) .. " ⓘ " , time_to_read_string , callback = estimated_popup , separator = true } ,
@ -1634,8 +1634,8 @@ function ReaderStatistics:getBookStat(id_book)
{ _ ( " Author(s) " ) , authors , separator = true } ,
{ _ ( " Author(s) " ) , authors , separator = true } ,
-- Time-focused book stats
-- Time-focused book stats
{ _ ( " Total time spent on this book " ) , datetime.secondsToClockDuration ( user_duration_format , total_time_book , false , true ) } ,
{ _ ( " Total time spent on this book " ) , datetime.secondsToClockDuration ( user_duration_format , total_time_book , false ) } ,
{ _ ( " Time spent reading " ) , datetime.secondsToClockDuration ( user_duration_format , book_read_time , false , true ), separator = true } ,
{ _ ( " Time spent reading " ) , datetime.secondsToClockDuration ( user_duration_format , book_read_time , false ), separator = true } ,
-- Day-focused book stats
-- Day-focused book stats
{ _ ( " Days reading this book " ) .. " " .. more_arrow , tonumber ( total_days ) ,
{ _ ( " Days reading this book " ) .. " " .. more_arrow , tonumber ( total_days ) ,
@ -1655,7 +1655,7 @@ function ReaderStatistics:getBookStat(id_book)
UIManager : show ( self.kv )
UIManager : show ( self.kv )
end ,
end ,
} ,
} ,
{ _ ( " Average time per day " ) , datetime.secondsToClockDuration ( user_duration_format , book_read_time / tonumber ( total_days ) , false , true ), separator = true } ,
{ _ ( " Average time per day " ) , datetime.secondsToClockDuration ( user_duration_format , book_read_time / tonumber ( total_days ) , false ), separator = true } ,
-- Date-focused book stats
-- Date-focused book stats
{ _ ( " Book start date " ) , T ( N_ ( " (1 day ago) %2 " , " (%1 days ago) %2 " , first_open_days_ago ) , first_open_days_ago , datetime.secondsToDate ( tonumber ( first_open ) , true ) ) } ,
{ _ ( " Book start date " ) , T ( N_ ( " (1 day ago) %2 " , " (%1 days ago) %2 " , first_open_days_ago ) , first_open_days_ago , datetime.secondsToDate ( tonumber ( first_open ) , true ) ) } ,
@ -1664,7 +1664,7 @@ function ReaderStatistics:getBookStat(id_book)
-- Page-focused book stats
-- Page-focused book stats
{ _ ( " Last read page/Total pages " ) , string.format ( " %d / %d (%d%%) " , last_page , pages , Math.round ( 100 * last_page / pages ) ) } ,
{ _ ( " Last read page/Total pages " ) , string.format ( " %d / %d (%d%%) " , last_page , pages , Math.round ( 100 * last_page / pages ) ) } ,
{ _ ( " Pages read " ) , string.format ( " %d (%d%%) " , total_read_pages , Math.round ( 100 * total_read_pages / pages ) ) } ,
{ _ ( " Pages read " ) , string.format ( " %d (%d%%) " , total_read_pages , Math.round ( 100 * total_read_pages / pages ) ) } ,
{ _ ( " Average time per page " ) , datetime.secondsToClockDuration ( user_duration_format , avg_time_per_page , false , true ), separator = true } ,
{ _ ( " Average time per page " ) , datetime.secondsToClockDuration ( user_duration_format , avg_time_per_page , false ), separator = true } ,
-- Highlights
-- Highlights
{ _ ( " Book highlights " ) , highlights } ,
{ _ ( " Book highlights " ) , highlights } ,
@ -1871,7 +1871,7 @@ function ReaderStatistics:getDatesFromAll(sdays, ptype, book_mode)
local stop_month = os.time { year = year_end , month = month_end , day = 1 , hour = 0 , min = 0 }
local stop_month = os.time { year = year_end , month = month_end , day = 1 , hour = 0 , min = 0 }
table.insert ( results , {
table.insert ( results , {
date_text ,
date_text ,
T ( N_ ( " %1 (%2 page) " , " %1 (%2 pages) " , tonumber ( result_book [ 2 ] [ i ] ) ) , datetime.secondsToClockDuration ( user_duration_format , tonumber ( result_book [ 3 ] [ i ] ) , false , true ), tonumber ( result_book [ 2 ] [ i ] ) ) ,
T ( N_ ( " %1 (%2 page) " , " %1 (%2 pages) " , tonumber ( result_book [ 2 ] [ i ] ) ) , datetime.secondsToClockDuration ( user_duration_format , tonumber ( result_book [ 3 ] [ i ] ) , false ), tonumber ( result_book [ 2 ] [ i ] ) ) ,
callback = function ( )
callback = function ( )
self : callbackMonthly ( start_month , stop_month , date_text , book_mode )
self : callbackMonthly ( start_month , stop_month , date_text , book_mode )
end ,
end ,
@ -1885,7 +1885,7 @@ function ReaderStatistics:getDatesFromAll(sdays, ptype, book_mode)
begin_week = begin_week - weekday * 86400
begin_week = begin_week - weekday * 86400
table.insert ( results , {
table.insert ( results , {
date_text ,
date_text ,
T ( N_ ( " %1 (%2 page) " , " %1 (%2 pages) " , tonumber ( result_book [ 2 ] [ i ] ) ) , datetime.secondsToClockDuration ( user_duration_format , tonumber ( result_book [ 3 ] [ i ] ) , false , true ), tonumber ( result_book [ 2 ] [ i ] ) ) ,
T ( N_ ( " %1 (%2 page) " , " %1 (%2 pages) " , tonumber ( result_book [ 2 ] [ i ] ) ) , datetime.secondsToClockDuration ( user_duration_format , tonumber ( result_book [ 3 ] [ i ] ) , false ), tonumber ( result_book [ 2 ] [ i ] ) ) ,
callback = function ( )
callback = function ( )
self : callbackWeekly ( begin_week , begin_week + 7 * 86400 , date_text , book_mode )
self : callbackWeekly ( begin_week , begin_week + 7 * 86400 , date_text , book_mode )
end ,
end ,
@ -1896,7 +1896,7 @@ function ReaderStatistics:getDatesFromAll(sdays, ptype, book_mode)
- 60 * tonumber ( string.sub ( time_book , 3 , 4 ) ) - tonumber ( string.sub ( time_book , 5 , 6 ) )
- 60 * tonumber ( string.sub ( time_book , 3 , 4 ) ) - tonumber ( string.sub ( time_book , 5 , 6 ) )
table.insert ( results , {
table.insert ( results , {
date_text ,
date_text ,
T ( N_ ( " %1 (%2 page) " , " %1 (%2 pages) " , tonumber ( result_book [ 2 ] [ i ] ) ) , datetime.secondsToClockDuration ( user_duration_format , tonumber ( result_book [ 3 ] [ i ] ) , false , true ), tonumber ( result_book [ 2 ] [ i ] ) ) ,
T ( N_ ( " %1 (%2 page) " , " %1 (%2 pages) " , tonumber ( result_book [ 2 ] [ i ] ) ) , datetime.secondsToClockDuration ( user_duration_format , tonumber ( result_book [ 3 ] [ i ] ) , false ), tonumber ( result_book [ 2 ] [ i ] ) ) ,
callback = function ( )
callback = function ( )
self : callbackDaily ( begin_day , begin_day + 86400 , date_text )
self : callbackDaily ( begin_day , begin_day + 86400 , date_text )
end ,
end ,
@ -1937,7 +1937,7 @@ function ReaderStatistics:getDaysFromPeriod(period_begin, period_end)
day = string.sub ( result_book [ 1 ] [ i ] , 9 , 10 ) , hour = 0 , min = 0 , sec = 0 }
day = string.sub ( result_book [ 1 ] [ i ] , 9 , 10 ) , hour = 0 , min = 0 , sec = 0 }
table.insert ( results , {
table.insert ( results , {
result_book [ 1 ] [ i ] ,
result_book [ 1 ] [ i ] ,
T ( N_ ( " %1 (%2 page) " , " %1 (%2 pages) " , tonumber ( result_book [ 2 ] [ i ] ) ) , datetime.secondsToClockDuration ( user_duration_format , tonumber ( result_book [ 3 ] [ i ] ) , false , true ), tonumber ( result_book [ 2 ] [ i ] ) ) ,
T ( N_ ( " %1 (%2 page) " , " %1 (%2 pages) " , tonumber ( result_book [ 2 ] [ i ] ) ) , datetime.secondsToClockDuration ( user_duration_format , tonumber ( result_book [ 3 ] [ i ] ) , false ), tonumber ( result_book [ 2 ] [ i ] ) ) ,
callback = function ( )
callback = function ( )
local kv = self.kv
local kv = self.kv
UIManager : close ( kv )
UIManager : close ( kv )
@ -1981,7 +1981,7 @@ function ReaderStatistics:getBooksFromPeriod(period_begin, period_end, callback_
for i = 1 , # result_book.title do
for i = 1 , # result_book.title do
table.insert ( results , {
table.insert ( results , {
result_book [ 1 ] [ i ] ,
result_book [ 1 ] [ i ] ,
T ( N_ ( " %1 (%2 page) " , " %1 (%2 pages) " , tonumber ( result_book [ 3 ] [ i ] ) ) , datetime.secondsToClockDuration ( user_duration_format , tonumber ( result_book [ 2 ] [ i ] ) , false , true ), tonumber ( result_book [ 3 ] [ i ] ) ) ,
T ( N_ ( " %1 (%2 page) " , " %1 (%2 pages) " , tonumber ( result_book [ 3 ] [ i ] ) ) , datetime.secondsToClockDuration ( user_duration_format , tonumber ( result_book [ 2 ] [ i ] ) , false ), tonumber ( result_book [ 3 ] [ i ] ) ) ,
book_id = tonumber ( result_book [ 4 ] [ i ] ) ,
book_id = tonumber ( result_book [ 4 ] [ i ] ) ,
callback = function ( )
callback = function ( )
local kv = self.kv
local kv = self.kv
@ -2089,7 +2089,7 @@ function ReaderStatistics:getDatesForBook(id_book)
for i = 1 , # result_book.dates do
for i = 1 , # result_book.dates do
table.insert ( results , {
table.insert ( results , {
result_book [ 1 ] [ i ] ,
result_book [ 1 ] [ i ] ,
T ( N_ ( " %1 (%2 page) " , " %1 (%2 pages) " , tonumber ( result_book [ 2 ] [ i ] ) ) , datetime.secondsToClockDuration ( user_duration_format , tonumber ( result_book [ 3 ] [ i ] ) , false , true ), tonumber ( result_book [ 2 ] [ i ] ) ) ,
T ( N_ ( " %1 (%2 page) " , " %1 (%2 pages) " , tonumber ( result_book [ 2 ] [ i ] ) ) , datetime.secondsToClockDuration ( user_duration_format , tonumber ( result_book [ 3 ] [ i ] ) , false ), tonumber ( result_book [ 2 ] [ i ] ) ) ,
hold_callback = function ( kv_page , kv_item )
hold_callback = function ( kv_page , kv_item )
self : resetStatsForBookForPeriod ( id_book , result_book [ 4 ] [ i ] , result_book [ 5 ] [ i ] , result_book [ 1 ] [ i ] , function ( )
self : resetStatsForBookForPeriod ( id_book , result_book [ 4 ] [ i ] , result_book [ 5 ] [ i ] , result_book [ 1 ] [ i ] , function ( )
kv_page : removeKeyValueItem ( kv_item ) -- Reset, refresh what's displayed
kv_page : removeKeyValueItem ( kv_item ) -- Reset, refresh what's displayed
@ -2188,7 +2188,7 @@ function ReaderStatistics:getTotalStats()
end
end
table.insert ( total_stats , {
table.insert ( total_stats , {
book_title ,
book_title ,
datetime.secondsToClockDuration ( user_duration_format , total_time_book , false , true ),
datetime.secondsToClockDuration ( user_duration_format , total_time_book , false ),
callback = function ( )
callback = function ( )
local kv = self.kv
local kv = self.kv
UIManager : close ( self.kv )
UIManager : close ( self.kv )
@ -2210,7 +2210,7 @@ function ReaderStatistics:getTotalStats()
end
end
conn : close ( )
conn : close ( )
return T ( _ ( " Total time spent reading: %1 " ) , datetime.secondsToClockDuration ( user_duration_format , total_books_time , false , true )) , total_stats
return T ( _ ( " Total time spent reading: %1 " ) , datetime.secondsToClockDuration ( user_duration_format , total_books_time , false )) , total_stats
end
end
function ReaderStatistics : genResetBookSubItemTable ( )
function ReaderStatistics : genResetBookSubItemTable ( )
@ -2290,7 +2290,7 @@ function ReaderStatistics:resetPerBook()
if id_book ~= self.id_curr_book then
if id_book ~= self.id_curr_book then
table.insert ( total_stats , {
table.insert ( total_stats , {
book_title ,
book_title ,
datetime.secondsToClockDuration ( user_duration_format , total_time_book , false , true ),
datetime.secondsToClockDuration ( user_duration_format , total_time_book , false ),
id_book ,
id_book ,
callback = function ( kv_page , kv_item )
callback = function ( kv_page , kv_item )
UIManager : show ( ConfirmBox : new {
UIManager : show ( ConfirmBox : new {