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 05-30-2021, 11:16 AM   #1
dunhill
Guru
dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.
 
dunhill's Avatar
 
Posts: 882
Karma: 409970
Join Date: Sep 2017
Location: Buenos Aires, Argentina
Device: moon+ reader, kindle paperwhite
Compute library book return date?

Hello people.
I have a library with a column with a loan date. Could you help me with a regular expression that calculates the date to be repaid from the date of the loan?
While i keep doing tests
Attached Thumbnails
Click image for larger version

Name:	1.png
Views:	92
Size:	69.5 KB
ID:	187413  
dunhill is offline   Reply With Quote
Old 05-30-2021, 02:57 PM   #2
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,404
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by dunhill View Post
Hello people.
I have a library with a column with a loan date. Could you help me with a regular expression that calculates the date to be repaid from the date of the loan?
While i keep doing tests
I don't think you mean "regular expression". Those look for patterns in strings and don't do calculation.

What calculation do you want to do? Is it something like ("loan date" + 10 days)?
chaley is offline   Reply With Quote
Advert
Old 05-30-2021, 03:19 PM   #3
dunhill
Guru
dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.
 
dunhill's Avatar
 
Posts: 882
Karma: 409970
Join Date: Sep 2017
Location: Buenos Aires, Argentina
Device: moon+ reader, kindle paperwhite
Quote:
Originally Posted by chaley View Post
I don't think you mean "regular expression". Those look for patterns in strings and don't do calculation.

What calculation do you want to do? Is it something like ("loan date" + 10 days)?
Exactly how to know the return date.
dunhill is offline   Reply With Quote
Old 05-30-2021, 03:25 PM   #4
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,404
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by dunhill View Post
Exactly how to know the return date.
You tell us. If I borrow the book on Monday 31/May/2021, when must I return it? If you don't know the answer to that question then there is no way for me to help you.
chaley is offline   Reply With Quote
Old 05-30-2021, 03:37 PM   #5
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,884
Karma: 74203799
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Unless you always borrow a book for the same duration, you'd probably want a second column with the length of the loan.
ownedbycats is offline   Reply With Quote
Advert
Old 05-30-2021, 03:45 PM   #6
crane3
Guru
crane3 ought to be getting tired of karma fortunes by now.crane3 ought to be getting tired of karma fortunes by now.crane3 ought to be getting tired of karma fortunes by now.crane3 ought to be getting tired of karma fortunes by now.crane3 ought to be getting tired of karma fortunes by now.crane3 ought to be getting tired of karma fortunes by now.crane3 ought to be getting tired of karma fortunes by now.crane3 ought to be getting tired of karma fortunes by now.crane3 ought to be getting tired of karma fortunes by now.crane3 ought to be getting tired of karma fortunes by now.crane3 ought to be getting tired of karma fortunes by now.
 
Posts: 608
Karma: 5007204
Join Date: Sep 2014
Location: Calif
Device: Fire hdx 8.9, Tab S2, Tab S5e, Aura ONE
Do not believe possible. My local library has a "normal" due date of 3 weeks from date of marking the book for loan & available for download. Then there are also many books that is for loan for just 2 weeks; another case is the the loan time is from a library in the consortium or borrowed from a university by the local library where the loan date is marked as available for download.

So which due date will anyone want the Calibre to "calculate"?
crane3 is offline   Reply With Quote
Old 05-30-2021, 05:04 PM   #7
dunhill
Guru
dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.
 
dunhill's Avatar
 
Posts: 882
Karma: 409970
Join Date: Sep 2017
Location: Buenos Aires, Argentina
Device: moon+ reader, kindle paperwhite
Quote:
Originally Posted by ownedbycats View Post
Unless you always borrow a book for the same duration, you'd probably want a second column with the length of the loan.
If I have a column to stipulate the days of the loan, I leave a screenshot.
Click image for larger version

Name:	1.png
Views:	83
Size:	63.6 KB
ID:	187434
Click image for larger version

Name:	2.png
Views:	79
Size:	11.6 KB
ID:	187433
#fechaprestamo = Loan date
#diasadevolver = Number of days (manual loading)
#adevolver = Date that would have to be returned

Moderator Notice
Edited to make the screen captures comply with forum rules.

Last edited by chaley; 05-31-2021 at 06:36 PM.
dunhill is offline   Reply With Quote
Old 05-31-2021, 02:15 PM   #8
dunhill
Guru
dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.
 
dunhill's Avatar
 
Posts: 882
Karma: 409970
Join Date: Sep 2017
Location: Buenos Aires, Argentina
Device: moon+ reader, kindle paperwhite
Quote:
Originally Posted by crane3 View Post
Do not believe possible. My local library has a "normal" due date of 3 weeks from date of marking the book for loan & available for download. Then there are also many books that is for loan for just 2 weeks; another case is the the loan time is from a library in the consortium or borrowed from a university by the local library where the loan date is marked as available for download.

So which due date will anyone want the Calibre to "calculate"?
And how do you have it configured?
dunhill is offline   Reply With Quote
Old 05-31-2021, 06:31 PM   #9
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,404
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Moderator Notice
Moved posts to a separate thread
chaley is offline   Reply With Quote
Old 05-31-2021, 09:33 PM   #10
crane3
Guru
crane3 ought to be getting tired of karma fortunes by now.crane3 ought to be getting tired of karma fortunes by now.crane3 ought to be getting tired of karma fortunes by now.crane3 ought to be getting tired of karma fortunes by now.crane3 ought to be getting tired of karma fortunes by now.crane3 ought to be getting tired of karma fortunes by now.crane3 ought to be getting tired of karma fortunes by now.crane3 ought to be getting tired of karma fortunes by now.crane3 ought to be getting tired of karma fortunes by now.crane3 ought to be getting tired of karma fortunes by now.crane3 ought to be getting tired of karma fortunes by now.
 
Posts: 608
Karma: 5007204
Join Date: Sep 2014
Location: Calif
Device: Fire hdx 8.9, Tab S2, Tab S5e, Aura ONE
I don't have any config for the "due date"; do not see the need for it nor do care; an advanatage of being retired & "on vacation" every day. I read the book after getting it then return it before it is due. Or my library sends a notice a few days before the need to return; did miss once as the email-id was off by 1 character by them.

Only problem occurs when multiple books were reserved & all of the books are available at the same time. Good thing for having multiple tablets so can read multiple books opened at the same time.
crane3 is offline   Reply With Quote
Old 06-01-2021, 11:04 AM   #11
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,404
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by chaley View Post
What calculation do you want to do? Is it something like ("loan date" + 10 days)?
I can't help you until you tell us what calculation you want to do.

Do you want
Code:
#adevolver (a computed date) = #fechaprestamo (a date) + #diasadevolver (count of days)
?
chaley is offline   Reply With Quote
Old 06-01-2021, 06:41 PM   #12
dunhill
Guru
dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.
 
dunhill's Avatar
 
Posts: 882
Karma: 409970
Join Date: Sep 2017
Location: Buenos Aires, Argentina
Device: moon+ reader, kindle paperwhite
Quote:
Originally Posted by chaley View Post
I can't help you until you tell us what calculation you want to do.

Do you want
Code:
#adevolver (a computed date) = #fechaprestamo (a date) + #diasadevolver (count of days)
?
I'd like
Code:
 #fechaprestamo (a date) + #diasadevolver (Manually entered in column) = #adevolver (a computed date)

Last edited by dunhill; 06-01-2021 at 06:48 PM.
dunhill is offline   Reply With Quote
Old 06-02-2021, 03:29 AM   #13
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,404
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
This should what you want, or at least close to it.
Code:
program:
# Calculate number of seconds in a day
	one_day = 60 * 60 * 24;
# Calculate total seconds for days of loan
	loan_seconds = one_day * $#diasadevolver;
# Get the start date in ISO format
	start_day = $$#fechaprestamo;
# Get the "timestamp" for the start date -- number of seconds since epoch
	start_ts = format_date(start_day, 'to_number');
# Add the number of seconds for the days of loan	
	end_ts = start_ts + loan_seconds;
# Convert the timestamp back into a datte
	end_ts = format_date(start_ts, 'from_number');
# Format the date as desired
	end_day = format_date(end_ts, 'yyyy MM dd')
chaley is offline   Reply With Quote
Old 06-02-2021, 04:59 AM   #14
un_pogaz
Chalut o/
un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.
 
un_pogaz's Avatar
 
Posts: 439
Karma: 145424
Join Date: Dec 2017
Device: Kobo
small error in
Code:
# Convert the timestamp back into a datte
	end_ts = format_date(start_ts, 'from_number');
Use end_ts instead of start_ts
un_pogaz is offline   Reply With Quote
Old 06-02-2021, 10:26 AM   #15
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,404
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by un_pogaz View Post
small error in
Code:
# Convert the timestamp back into a datte
	end_ts = format_date(start_ts, 'from_number');
Use end_ts instead of start_ts
Thanks for that.

There is an optimization available. 'from_number' also accepts the date format, so you can use:
Code:
# Convert the timestamp back into a datte
# Format the date as desired
	format_date(end_ts, 'from_number:yyyy MM dd')
Here is the entire template with un_pogaz's correction and the optimization
Code:
program:
# Calculate number of seconds in a day
	one_day = 60 * 60 * 24;
# Calculate total seconds for days of loan
	loan_seconds = one_day * $#diasadevolver;
# Get the start date in ISO format
	start_day = $$#fechaprestamo;
# Get the "timestamp" for the start date -- number of seconds since epoch
	start_ts = format_date(start_day, 'to_number');
# Add the number of seconds for the days of loan	
	end_ts = start_ts + loan_seconds;
# Convert the timestamp back into a date
# Format the date as desired
	format_date(end_ts, 'from_number:yyyy MM dd');
chaley is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
date of adding book to my library is incorrect judet Library Management 2 01-21-2014 12:47 PM
Need to return to the library display renzii Library Management 4 06-28-2013 06:53 PM
Date Added column? Can I set date when book added to library? fitzhugh Calibre 4 06-03-2012 05:42 PM
Return Book to Library Early Maggie-Me Kindle Formats 8 01-17-2011 10:43 AM
Return Book to Library Early Maggie-Me General Discussions 15 12-24-2010 08:58 PM


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


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