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 03-07-2021, 06:49 AM   #16
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: 11,733
Karma: 6690881
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
7 Mar 2021 (calibre 5.13):
  • Fix regression introduced sometime in calibre V5: expression lists as parameters

    In calibre versions before V5.something one could use expression lists as parameters. Example:
    Code:
    program:
        list_union(
    	a = 'xxx'; list_union('a', field('tags'), ','), 
    	field('#genre'),
    	','
        )
    This 'feature' was certainly rarely used but it was possible. Fixed in the interest of compatibility.
  • Allow expression lists in parenthesized expressions.

    As a consequence of the above, you can now put expression lists in parenthesized expressions. Example:
    Code:
    program:
    	b = (
    		a = field('#mytextmult');
    		list_union(a, field('tags'), ',')
    	);
    	if a then
    		list_union(b, field('#genre'), ',')
    	else
    		b
    	fi

Last edited by chaley; 03-11-2021 at 01:55 PM.
chaley is offline   Reply With Quote
Old 03-13-2021, 12:20 PM   #17
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: 11,733
Karma: 6690881
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
11 Mar 2021 (in calibre source):
  • Performance improvement of the virtual_libraries() template function

    The performance of the virtual_libraries function has been improved substantially. For example, on my Windows machine using a test database with 3900 books, 15 virtual libraries, and one composite column that calls virtual_libraries(), the performance change is:
    Code:
    First call to virtual_libraries()
                 old = 368,381 μs
                 new = 382,352 μs
    
    Typical time for each call thereafter (once per displayed book), until data changes:
                 old = 165,338 μs
                 new =       1 μs
    Result: scrolling 20 books goes from 3.3 seconds to 20 microseconds.

    On a smaller library of 200 books with 5 virtual libraries the numbers are:
    Code:
    First call to virtual_libraries()
                 old = 7,852 μs
                 new = 7,846  μs
    
    Typical time for each call thereafter, until data changes:
                 old = 195 μs
                 new =  <1 μs
    The performance improvement is directly related to the number of virtual libraries.

Last edited by chaley; 03-13-2021 at 02:12 PM.
chaley is offline   Reply With Quote
Advert
Old 03-20-2021, 07:16 PM   #18
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: 11,733
Karma: 6690881
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
20 Mar 2021 (in calibre source):
  • Template tester improvement

    If you select multiple books before launching the template tester then it will show you the template evaluation result for each book.

Last edited by chaley; 03-20-2021 at 08:38 PM.
chaley is offline   Reply With Quote
Old 03-24-2021, 09:19 AM   #19
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: 11,733
Karma: 6690881
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
24 Mar 2021 (in calibre source)
  • Addition of field references

    You can now use $lookup_key instead of field('lookup_key') and $$lookup_key instead of raw_field('lookup_key'). Examples:
    Code:
      * $authors ==> field('authors')
      * $#genre ==> field('#genre')
      * $$pubdate ==> raw_field('pubdate')
      * $$#my_int ==> raw_field('#my_int')
chaley is offline   Reply With Quote
Old 03-24-2021, 07:21 PM   #20
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,907
Karma: 47303748
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
Quote:
Originally Posted by chaley View Post
24 Mar 2021 (in calibre source)
  • Addition of field references

    You can now use $lookup_key instead of field('lookup_key') and $$lookup_key instead of raw_field('lookup_key'). Examples:
    Code:
      * $authors ==> field('authors')
      * $#genre ==> field('#genre')
      * $$pubdate ==> raw_field('pubdate')
      * $$#my_int ==> raw_field('#my_int')
Not sure if I like this. My templates are going to look like Perl
davidfor is offline   Reply With Quote
Advert
Old 03-24-2021, 07:40 PM   #21
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: 11,733
Karma: 6690881
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by davidfor View Post
Not sure if I like this. My templates are going to look like Perl
Oh yes! Next is
Code:
 if $line =~ /^firstweek: *(.*)/ then
And for PHP fans
Code:
<?GPM echo bgcolor($ForumTableHeaderColor); ?>
And of course
Code:
HCF(0x9D)
(Actually, perhaps I should have used =~ instead of the 'in' operator. )
chaley is offline   Reply With Quote
Old 03-24-2021, 07:56 PM   #22
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: 8,557
Karma: 61170925
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Quote:
Originally Posted by davidfor View Post
Not sure if I like this. My templates are going to look like Perl
https://www.famicol.in/sigbovik/
ownedbycats is online now   Reply With Quote
Old 03-26-2021, 04:23 AM   #23
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: 11,733
Karma: 6690881
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
26 Mar 2021 (in calibre version 5.14)
  • Add new date formats 'to_number' and 'from_number'

    You can now convert dates to/from a floating point number representing the number of seconds since some platform-dependent start point. This number is sometimes called a 'timestamp'. Number-format dates are easier to compare and to modify using arithmetic. Details:
    • to_number : convert the date & time into a floating point number (a `timestamp`)
    • from_number : convert a floating point number (a `timestamp`) into an 'iso' formatted date. If you want a different date format then add the desired formatting string after 'from_number' and a colon (':'). Example:
      from_number:MMM dd yyyy
chaley is offline   Reply With Quote
Old 03-26-2021, 05:03 PM   #24
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: 8,557
Karma: 61170925
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Question: Is there a way to set an arbitrary epoch? I can see some strangeness otherwise, e.g. if to_number is used to store it to a column on *nix environment, then from_number is used on that stored number in Windows environment. Though I am not sure why someone would do this.

Also, does the number work in negative, e.g. someone on a *nix system using to_number on a date earlier than 1970?

Last edited by ownedbycats; 03-26-2021 at 05:16 PM.
ownedbycats is online now   Reply With Quote
Old 03-26-2021, 05:45 PM   #25
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,085
Karma: 1948136
Join Date: Aug 2015
Device: Kindle
I think python implementation for this sticks with POSIX timestamp regardless of operating system (might be wrong on this). I don't have Windows to test on. But you can test the ouput of this template:

Code:
program:
	format_date('1900-01-01T00:00:00+00:00', 'to_number')
On my linux system it returns: -2208988800.0
capink is offline   Reply With Quote
Old 03-26-2021, 06:06 PM   #26
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: 8,557
Karma: 61170925
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
I got the same result on a Windows environment. That's good that it stays the same.
ownedbycats is online now   Reply With Quote
Old 03-26-2021, 06:35 PM   #27
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: 11,733
Karma: 6690881
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
Question: Is there a way to set an arbitrary epoch? I can see some strangeness otherwise, e.g. if to_number is used to store it to a column on *nix environment, then from_number is used on that stored number in Windows environment. Though I am not sure why someone would do this.
No. You shouldn't store the numbers. Instead store an iso-formatted date, which is guaranteed to be valid cross platform.
Quote:
Also, does the number work in negative, e.g. someone on a *nix system using to_number on a date earlier than 1970?
Maybe, as long as that is what python does. But you should banish the idea of the number being related to *nix systems. There is zero guarantee of that. The python documents say
Quote:
  • The epoch is the point where the time starts, and is platform dependent. For Unix, the epoch is January 1, 1970, 00:00:00 (UTC).
  • The term seconds since the epoch refers to the total number of elapsed seconds since the epoch, typically excluding leap seconds. Leap seconds are excluded from this total on all POSIX-compliant platforms.
  • The functions in this module may not handle dates and times before the epoch or far in the future. The cut-off point in the future is determined by the C library; for 32-bit systems, it is typically in 2038.
Quote:
Originally Posted by capink View Post
I think python implementation for this sticks with POSIX timestamp regardless of operating system (might be wrong on this). I don't have Windows to test on. But you can test the ouput of this template:

Code:
program:
	format_date('1900-01-01T00:00:00+00:00', 'to_number')
On my linux system it returns: -2208988800.0
See the above
Quote:
Originally Posted by ownedbycats View Post
I got the same result on a Windows environment. That's good that it stays the same.
I wouldn't depend on this if I were you.

My take: these numbers are good for comparing dates and doing arithmetic on dates, but not much else.
chaley is offline   Reply With Quote
Old 03-26-2021, 07:02 PM   #28
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: 8,557
Karma: 61170925
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Also I was experimenting and came across something strange

The highest date available in the Calibre date fields seems to be 9999-12-31 so I put this in:

Code:
program:
	format_date('9999-12-31T23:59:59+00:00', 'to_number')
which resulted in 253402300799.0

So I put that back in this:

Code:
program:
	format_date('253402300799.0', 'from_number')
and got a BAD DATE error. I wonder why. maybe I put the date in wrong the first template.

Last edited by ownedbycats; 03-26-2021 at 07:09 PM.
ownedbycats is online now   Reply With Quote
Old 03-26-2021, 07:31 PM   #29
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: 11,733
Karma: 6690881
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Thumbs up

Quote:
Originally Posted by ownedbycats View Post
Also I was experimenting and came across something strange

The highest date available in the Calibre date fields seems to be 9999-12-31 so I put this in:

Code:
program:
	format_date('9999-12-31T23:59:59+00:00', 'to_number')
which resulted in 253402300799.0

So I put that back in this:

Code:
program:
	format_date('253402300799.0', 'from_number')
and got a BAD DATE error. I wonder why. maybe I put the date in wrong the first template.
You have found one of the fundamental problems with timestamps: they can represent only a subset of dates. Exactly what that subset is depends on the platform.

For example, on windows this expression works:
Code:
	format_date(1031*(365*24*60*60), 'from_number')
The number is (approximately) 1032 years in the future from the epoch. It produces 3000-04-26T01:00:00+01:00.

The 2032 year-in-the-future expression
Code:
	format_date(1032*(365*24*60*60), 'from_number')
produces "BAD DATE", which means that python threw an exception.

For more bad news see Year 2038 problem.

Bottom line: you can't trust timestamps.
chaley is offline   Reply With Quote
Old 03-26-2021, 08:03 PM   #30
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: 8,557
Karma: 61170925
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Deep Impact was lost because the date was stored as an unsigned 32-bit integer that overflowed.
ownedbycats is online now   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
A few questions... (template language, mainly) Clem2605 Library Management 2 12-30-2020 03:25 AM
Template Language phossler Calibre 8 01-12-2016 04:37 PM
Help needed with template language Mamaijee Devices 12 02-19-2013 01:52 AM
Help with template language Pepin33 Calibre 8 11-11-2012 08:32 AM
Template language question BookJunkieLI Library Management 7 02-02-2012 06:55 PM


All times are GMT -4. The time now is 10:44 AM.


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