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 01-01-2021, 10:43 PM   #1
BetterRed
null operator (he/him)
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 21,716
Karma: 29711016
Join Date: Mar 2012
Location: Sydney Australia
Device: none
Imprecise Dates

Does anyone have a solution for dealing with dates that are sometimes imprecise, in that sometimes you have a year, at others a year and a month and at others a year, month and a day..

I don't like having pretend dates as in 1985-01-01, I would rather have something like 1985-??-?? or 2014-05-??

BR
BetterRed is offline   Reply With Quote
Old 01-01-2021, 11:10 PM   #2
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 could use a composite column with conditional formatting. Problem is how would you tell whether a date like 1985-01-01 is an actual date or a pretend date?

If you will presume that every date that starts with 01-01 is a pretend date, a template like this should work:

Code:
program:
	m = format_date(field('timestamp'), 'M');
	d = format_date(field('timestamp'), 'd');
	if m == 1 then
		if d == 1 then
			format_date(field('timestamp'), 'yyyy')
		else
			format_date(field('timestamp'), 'dd-MM-yyyy')
		fi
	else
		format_date(field('timestamp'), 'dd-MM-yyyy')
	fi
capink is offline   Reply With Quote
Advert
Old 01-02-2021, 05:14 AM   #3
BetterRed
null operator (he/him)
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 21,716
Karma: 29711016
Join Date: Mar 2012
Location: Sydney Australia
Device: none
IIRC composite columns are display only. I want to enter yyyy, or yyyy-MM, or yyyy-MM-dd into a custom column - and do it in the Book list. Maybe I could enter it as three parts (ints), and build a composite column from the parts for display purposes - but I'd need to validate the parts…

BR
BetterRed is offline   Reply With Quote
Old 01-02-2021, 10:36 AM   #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,440
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
I would consider adding 2 columns: one text column to enter the date and a composite column to display it.

You would enter the date using some version of a string that supplies the numbers and the desired format. Example:
Y,1984
YM,1984,12
YMD,1984,12,04
The template for the composite column would split the "list" into its component parts then reassemble them as desired. Something like:
Code:
program:
# date_string = field('#other_column')
	date_string = 'YMD,1984,12, 01';
	format = list_item(date_string, 0, ',');
	if format == 'YMD' then
		strcat(
			list_item(date_string, 1, ','), '-',
			list_item(date_string, 2, ','), '-',
			list_item(date_string, 3, ',')
		)
	elif format == 'YM'  then
		strcat(
			list_item(date_string, 1, ','), '-',
			list_item(date_string, 2, ',')
		)
	elif format == 'Y'  then
			list_item(date_string, 1, ',')
	else
			'Invalid Format'
	fi

Last edited by chaley; 01-03-2021 at 06:22 AM. Reason: Fix template
chaley is offline   Reply With Quote
Old 01-03-2021, 06:26 AM   #5
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,440
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Here is a more compact template that uses the list_split function that will be in the next calibre release (5.9).
Code:
program:
# date_string = field('#other_column')
	date_string = 'YMD,1984,12, 01';
	list_split(date_string, ',', 'li');
	if li_0 == 'YMD' then
		strcat(li_1, '-', li_2, '-', li_3)
	elif li_0 == 'YM'  then
		strcat(li_1, '-', li_2)
	elif li_0 == 'Y'  then
		li_1
	else
		'Invalid Format'
	fi
chaley is offline   Reply With Quote
Advert
Old 01-03-2021, 03:41 PM   #6
BetterRed
null operator (he/him)
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 21,716
Karma: 29711016
Join Date: Mar 2012
Location: Sydney Australia
Device: none
Thanks chaley, but in the middle of the night had an idea.

I made my #release/Release date column tag-like and hierarchical.

So, I can enter yyyy, or yyyy.mm or yyyy.mm.dd. Which suits me because I always write dates as four digit year, two digit month, and two digit day. Not sure if it would work for people write dates otherwise.

Aside: In the Tag browser:

If I click on 1986 I get books that that do not have a month specified, i.e. the search is always #mydate:(=1986), I expected it to be #mydate:(1986). Perhaps there needs to be a Tag Browser setting to specify if searches of hierarchical categories should create contains, starts with, or equals search terms.

If it exists, pray tell where 'tis - apart from advanced search.

BR
BetterRed is offline   Reply With Quote
Old 01-03-2021, 03:56 PM   #7
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,440
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by BetterRed View Post
Aside: In the Tag browser:

If I click on 1986 I get books that that do not have a month specified, i.e. the search is always #mydate:(=1986), I expected it to be #mydate:(1986). Perhaps there needs to be a Tag Browser setting to specify if searches of hierarchical categories should create contains, starts with, or equals search terms.

If it exists, pray tell where 'tis - apart from advanced search.

BR
For hierarchical categories the first click gives you an exact match, for example #text:"=2010". A second click gives you a hierarchical prefix match indicated by a 2-plus icon, for example #text:"=.2010", which selects all matching and child books. The dot is important, telling the search that you are looking for anything that matches X or anything that is a child of X. The same thing is true for "anything but" searches, but with a minus and 2-minus icons.

I don't know why you are seeing the parentheses when you click. I don't see them.

Why is it tag-like? Can you enter more than one date per book?
chaley is offline   Reply With Quote
Old 01-03-2021, 05:04 PM   #8
BetterRed
null operator (he/him)
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 21,716
Karma: 29711016
Join Date: Mar 2012
Location: Sydney Australia
Device: none
There is no option in the context menu Search flyout (which is where I started) to do a search that includes children, i.e. the equivalent of double click for keyboard addicts. So, when I found Single click was the same as Search->Search for 1986 I went looking for a setting.

The parentheses are in my mind, probably legacy of maintaining social distance between search terms, and I dunno why I made it tag like… seemed like a good idea at 4:20 in the morning

BR
BetterRed is offline   Reply With Quote
Old 01-03-2021, 05:56 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,440
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by BetterRed View Post
There is no option in the context menu Search flyout (which is where I started) to do a search that includes children, i.e. the equivalent of double click for keyboard addicts.
I will add context menu options to search for [not] X and children of X.
chaley is offline   Reply With Quote
Old 01-03-2021, 06:02 PM   #10
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,440
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by BetterRed View Post
seemed like a good idea at 4:20 in the morning
Perhaps you were worried about the covid variant and decided to inject bleach. That would certainly affect mental processes.
chaley is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get your Kobo to use non-US dates GeoffR Kobo Reader 167 10-11-2021 07:34 AM
REGEX And Dates thomasm1964 Conversion 1 03-03-2017 11:36 PM
Published - Dates bigbird1227 Plugins 4 08-21-2011 06:54 AM
Published Dates bigbird1227 Library Management 7 06-10-2011 10:40 AM
Dates in Russian (?) Roger Wilmut Calibre 10 11-24-2008 06:22 PM


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


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