@ -1074,6 +1074,46 @@ The max value ensures a page you stay on for a long time (because you fell aslee
end ,
separator = true ,
} ,
{
text_func = function ( )
-- @translators %1 is the time in the format 00:00
return T ( _ ( " Daily timeline starts at %1 " ) ,
string.format ( " %02d:%02d " , self.settings . calendar_day_start_hour or 0 ,
self.settings . calendar_day_start_minute or 0 )
)
end ,
callback = function ( touchmenu_instance )
local DateTimeWidget = require ( " ui/widget/datetimewidget " )
local start_of_day_widget = DateTimeWidget : new {
hour = self.settings . calendar_day_start_hour or 0 ,
min = self.settings . calendar_day_start_minute or 0 ,
hour_max = 6 ,
ok_text = _ ( " Set time " ) ,
title_text = _ ( " Daily timeline starts at " ) ,
info_text = _ ( [ [
Set the time when the daily timeline should start .
If you read past midnight , and would like this reading session to be displayed on the same screen with your previous evening reading sessions , use a value such as 04 : 00.
Time is in hours and minutes . ] ] ) ,
callback = function ( time )
self.settings . calendar_day_start_hour = time.hour
self.settings . calendar_day_start_minute = time.min
touchmenu_instance : updateItems ( )
end
}
UIManager : show ( start_of_day_widget )
end ,
keep_menu_open = true ,
} ,
{
text = _ ( " Also use in calendar view " ) ,
checked_func = function ( ) return self.settings . calendar_use_day_time_shift end ,
callback = function ( )
self.settings . calendar_use_day_time_shift = not self.settings . calendar_use_day_time_shift
end ,
separator = true ,
} ,
{
text = _ ( " Cloud sync " ) ,
callback = function ( touchmenu_instance )
@ -2004,6 +2044,7 @@ function ReaderStatistics:getBooksFromPeriod(period_begin, period_end, callback_
table.insert ( results , {
result_book [ 1 ] [ i ] ,
T ( N_ ( " %1 (1 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 ] ) ) ,
duration = tonumber ( result_book [ 3 ] [ i ] ) ,
book_id = tonumber ( result_book [ 4 ] [ i ] ) ,
callback = function ( )
local kv = self.kv
@ -2699,14 +2740,20 @@ function ReaderStatistics:getReadingRatioPerHourByDay(month)
-- We let SQLite compute these timestamp boundaries from the provided
-- month; we need the start of the month to be a real date:
month = month .. " -01 "
local offset = not self.settings . calendar_use_day_time_shift and 0 or ( self.settings . calendar_day_start_hour or 0 ) * 3600 + ( self.settings . calendar_day_start_minute or 0 ) * 60
local sql_stmt = [ [
SELECT
strftime ( ' %Y-%m-%d ' , start_time , ' unixepoch ' , ' localtime ' ) day ,
strftime ( ' %H ' , start_time , ' unixepoch ' , ' localtime ' ) hour ,
sum ( duration ) / 3600.0 ratio
FROM page_stat
WHERE start_time BETWEEN strftime ( ' %s ' , ? , ' utc ' )
AND strftime ( ' %s ' , ? , ' utc ' , ' +33 days ' , ' start of month ' , ' -1 second ' )
FROM (
SELECT
start_time - ? as start_time ,
duration
FROM page_stat
WHERE start_time BETWEEN strftime ( ' %s ' , ? , ' utc ' )
AND strftime ( ' %s ' , ? , ' utc ' , ' +33 days ' , ' start of month ' , ' -1 second ' )
)
GROUP BY
strftime ( ' %Y-%m-%d ' , start_time , ' unixepoch ' , ' localtime ' ) ,
strftime ( ' %H ' , start_time , ' unixepoch ' , ' localtime ' )
@ -2714,7 +2761,7 @@ function ReaderStatistics:getReadingRatioPerHourByDay(month)
] ]
local conn = SQ3.open ( db_location )
local stmt = conn : prepare ( sql_stmt )
local res , nb = stmt : reset ( ) : bind ( month, month ) : resultset ( " i " )
local res , nb = stmt : reset ( ) : bind ( offset, month, month ) : resultset ( " i " )
stmt : close ( )
conn : close ( )
local per_day = { }
@ -2731,16 +2778,20 @@ end
function ReaderStatistics : getReadBookByDay ( month )
month = month .. " -01 "
local offset = not self.settings . calendar_use_day_time_shift and 0 or ( self.settings . calendar_day_start_hour or 0 ) * 3600 + ( self.settings . calendar_day_start_minute or 0 ) * 60
local sql_stmt = [ [
SELECT
strftime ( ' %Y-%m-%d ' , start_time , ' unixepoch ' , ' localtime ' ) day ,
sum ( duration ) durations ,
id_book book_id ,
book.title book_title
FROM page_stat
JOIN book ON book.id = page_stat.id_book
WHERE start_time BETWEEN strftime ( ' %s ' , ? , ' utc ' )
AND strftime ( ' %s ' , ? , ' utc ' , ' +33 days ' , ' start of month ' , ' -1 second ' )
title book_title
FROM (
SELECT start_time - ? as start_time , duration , page_stat.id_book , book.title
FROM page_stat
JOIN book ON book.id = page_stat.id_book
WHERE start_time BETWEEN strftime ( ' %s ' , ? , ' utc ' )
AND strftime ( ' %s ' , ? , ' utc ' , ' +33 days ' , ' start of month ' , ' -1 second ' )
)
GROUP BY
strftime ( ' %Y-%m-%d ' , start_time , ' unixepoch ' , ' localtime ' ) ,
id_book ,
@ -2749,7 +2800,7 @@ function ReaderStatistics:getReadBookByDay(month)
] ]
local conn = SQ3.open ( db_location )
local stmt = conn : prepare ( sql_stmt )
local res , nb = stmt : reset ( ) : bind ( month, month ) : resultset ( " i " )
local res , nb = stmt : reset ( ) : bind ( offset, month, month ) : resultset ( " i " )
stmt : close ( )
conn : close ( )
local per_day = { }