|
|
#1 |
|
null operator (he/him)
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 22,034
Karma: 30277960
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 |
|
|
|
|
|
#2 |
|
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,216
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
|
|
|
|
| Advert | |
|
|
|
|
#3 |
|
null operator (he/him)
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 22,034
Karma: 30277960
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 |
|
|
|
|
|
#4 |
|
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,526
Karma: 8065948
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 07:22 AM. Reason: Fix template |
|
|
|
|
|
#5 |
|
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,526
Karma: 8065948
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
|
|
|
|
| Advert | |
|
|
|
|
#6 |
|
null operator (he/him)
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 22,034
Karma: 30277960
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 |
|
|
|
|
|
#7 | |
|
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,526
Karma: 8065948
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
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? |
|
|
|
|
|
|
#8 |
|
null operator (he/him)
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 22,034
Karma: 30277960
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 |
|
|
|
|
|
#9 |
|
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,526
Karma: 8065948
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
|
|
|
|
|
|
#10 |
|
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,526
Karma: 8065948
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
|
|
|
|
![]() |
|
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 08:34 AM |
| REGEX And Dates | thomasm1964 | Conversion | 1 | 03-04-2017 12:36 AM |
| Published - Dates | bigbird1227 | Plugins | 4 | 08-21-2011 07:54 AM |
| Published Dates | bigbird1227 | Library Management | 7 | 06-10-2011 11:40 AM |
| Dates in Russian (?) | Roger Wilmut | Calibre | 10 | 11-24-2008 07:22 PM |