Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Library Management

Notices

Reply
 
Thread Tools Search this Thread
Old 10-03-2021, 03:16 PM   #166
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 10,998
Karma: 75337983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Why does program: raw_field('date') return "None" while field('date') works?

$date and $$date get the same result.

EDIT: It happens even if I set gui_pubdate_display_format back to default.

ANOTHER EDIT: For reference, I'm using search & replace to copy to another datetime field.

Last edited by ownedbycats; 10-03-2021 at 03:32 PM.
ownedbycats is offline   Reply With Quote
Old 10-03-2021, 04:22 PM   #167
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
Why does program: raw_field('date') return "None" while field('date') works?

$date and $$date get the same result.

EDIT: It happens even if I set gui_pubdate_display_format back to default.

ANOTHER EDIT: For reference, I'm using search & replace to copy to another datetime field.
It happens because 'date' is an alias for the (historically) real field 'timestamp'. The field() function does the translation. The raw_field() function doesn't.

Workaround: use 'timestamp' instead of 'date'.

EDIT: Also & FWIW: raw_field for dates returns 0101-01-01 00:00:00+00:00 for the unknown date because that is what is stored in the db. Up to you to know what to do with it.

Last edited by chaley; 10-03-2021 at 04:25 PM.
chaley is offline   Reply With Quote
Advert
Old 10-03-2021, 06:36 PM   #168
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 10,998
Karma: 75337983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Thank you.

Are there any other columns with alias that don't work with raw_field?
ownedbycats is offline   Reply With Quote
Old 10-03-2021, 06:41 PM   #169
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 10,998
Karma: 75337983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Another question: Is it possible to use a template to search datetimes where the timestamp is 00:00, regardless of date?
ownedbycats is offline   Reply With Quote
Old 10-04-2021, 03:40 AM   #170
capink
Wizard
capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.
 
Posts: 1,196
Karma: 1995558
Join Date: Aug 2015
Device: Kindle
You can use the following template:

Code:
program:
	ts = raw_field('timestamp');
	time_timezone = list_item(ts, 1, ' ');
	time = list_item(time_timezone, 0, '+');
	hours = list_item(time, 0, ':');
	minutes = list_item(time, 1, ':');
	seconds = list_item(time, 2, ':');
	strcat(hours, ':', minutes)
Search bar > settings icon > template tab > copy/paste the template above in the template cell, and in template value should be "00:00". Datatype should be "text".

Instead, you can do it by copy/pasting this directly into the search bar:

Code:
template:"program:
	ts = raw_field('timestamp');
	time_timezone = list_item(ts, 1, ' ');
	time = list_item(time_timezone, 0, '+');
	hours = list_item(time, 0, ':');
	minutes = list_item(time, 1, ':');
	seconds = list_item(time, 2, ':');
	strcat(hours, ':', minutes)#@#:t:00:00"
Edit: I tried the format_date() but for some reason it is not working:

Code:
template:"program:
	format_date($$timestamp, 'hh:mm')#@#:t:00:00"

Last edited by capink; 10-04-2021 at 03:47 AM.
capink is offline   Reply With Quote
Advert
Old 10-04-2021, 04:33 AM   #171
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
Thank you.

Are there any other columns with alias that don't work with raw_field?
Not that I know of. And in any event I am making raw_field() do the same alias replacement as field().

EDIT: The change is now in calibre source.

Last edited by chaley; 10-04-2021 at 05:14 AM. Reason: Note that the change was accepted
chaley is offline   Reply With Quote
Old 10-04-2021, 05:02 AM   #172
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by capink View Post
Edit: I tried the format_date() but for some reason it is not working:

Code:
template:"program:
	format_date($$timestamp, 'hh:mm')#@#:t:00:00"
Timestamps are stored in UTC. The format_date() function converts them to local time (in the current time zone), including summer time adjustments if any. Your template ignores the time zone so times are not adjusted.

It seems to me that the format_date() answer is the right one because time zones should be accounted for. However, if you don't want that then this template removes time zone from the ISO string turning it into a local time.
Code:
	format_date(re($$timestamp, '(\+.*$)', ''), 'hh:mm')
chaley is offline   Reply With Quote
Old 10-04-2021, 05:47 AM   #173
capink
Wizard
capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.
 
Posts: 1,196
Karma: 1995558
Join Date: Aug 2015
Device: Kindle
That makes sense. Thanks.
capink is offline   Reply With Quote
Old 10-05-2021, 09:15 AM   #174
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 10,998
Karma: 75337983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Thank you.

Any idea why the template search in #170 runs inconsistently on custom datetime fields? It only returns #fanficupdated values that are from the last few days, and nothing at all from #lastmodified. I don't think it's the formatting of the columns - it's using raw_field.
ownedbycats is offline   Reply With Quote
Old 10-06-2021, 06:08 AM   #175
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
Thank you.

Any idea why the template search in #170 runs inconsistently on custom datetime fields? It only returns #fanficupdated values that are from the last few days, and nothing at all from #lastmodified. I don't think it's the formatting of the columns - it's using raw_field.
My guess is that you are not in the UTC time zone so the value you see is not the value stored in the database. See 3 posts back. Try the template @capink posted that takes the time zone into account:
Code:
template:"program:
	format_date($$timestamp, 'hh:mm')#@#:t:00:00"
If that doesn't work then we will need example failing raw_date() text to find the problem. Something like the output of this template:
Code:
program:
	strcat($$timestamp, ' ::: ', format_date($$timestamp, 'hh:mm'))
chaley is offline   Reply With Quote
Old 10-12-2021, 12:57 AM   #176
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 10,998
Karma: 75337983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Question:

I had this proof-of-concept template for making different icons based on is_marked values.

Code:
program:
m = is_marked();

first_non_empty
   (
    contains(m, "invalid_author_sort", 'test.png', ''),
    contains(m, "invalid_title_sort", 'test2.png', ''),
   )
But how do I set a value for a non-defined mark?

Last edited by ownedbycats; 10-12-2021 at 01:21 AM.
ownedbycats is offline   Reply With Quote
Old 10-12-2021, 04:40 AM   #177
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
Question:

I had this proof-of-concept template for making different icons based on is_marked values.

Code:
program:
m = is_marked();

first_non_empty
   (
    contains(m, "invalid_author_sort", 'test.png', ''),
    contains(m, "invalid_title_sort", 'test2.png', ''),
   )
But how do I set a value for a non-defined mark?
Do you mean no marks or not one of the ones you have tested for? If you mean no marks then
Code:
program:
m = is_marked();

first_non_empty
   (
    contains(m, "invalid_author_sort", 'test.png', ''),
    contains(m, "invalid_title_sort", 'test2.png', ''),
    if !m then 'foo.png' fi
   )
If you mean any mark other than the ones above then remove the !.
chaley is offline   Reply With Quote
Old 10-12-2021, 11:16 AM   #178
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 10,998
Karma: 75337983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Thank you
ownedbycats is offline   Reply With Quote
Old 10-12-2021, 09:51 PM   #179
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 10,998
Karma: 75337983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Quote:
if
!approximate_formats() then 'foo'
fi
Is this actually the correct way to check for no formats? It works, at least.
ownedbycats is offline   Reply With Quote
Old 10-13-2021, 06:03 AM   #180
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
Is this actually the correct way to check for no formats? It works, at least.
Yes, it is a correct way as long as your database correctly lists the formats. If Check Library phase 2 passes then you are fine.

FWIW: this does the same thing but is less efficient because of the explicit compare:
Code:
if approximate_formats() == '' then 'foo' fi
chaley is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Library Management: various questions not worth their own thread ownedbycats Library Management 225 07-27-2025 02:07 PM
[Metadata Source Plugin] Questions regarding parse select, docs and ref templates Boilerplate4U Development 13 07-07-2020 02:35 AM
Questions on Kobo [Interfered with another thread topic] spdavies Kobo Reader 8 10-12-2014 11:37 AM
[OLD Thread] Some questions before buying the fire. darthreader13 Kindle Fire 7 05-10-2013 09:19 PM
Thread management questions meme Feedback 6 01-31-2011 05:07 PM


All times are GMT -4. The time now is 07:26 AM.


MobileRead.com is a privately owned, operated and funded community.