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-22-2024, 07:48 PM   #661
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,620
Karma: 61176603
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
format_date and partial dates

I'm using this template to display a list of dates formatted as 'yyyy-MM-dd' as 'MMM d yyyy':

Code:
program:

	new_dates = '';

	for dates in '#datesread':
		converted = format_date(dates, 'MMM d yyyy');
		new_dates = list_union(new_dates, converted, ',')
	rof
However, several entries are just a year; e.g. '2017, 2023-06-13.' When I run them through this template, it ends up filling in the rest of the date so it becomes 2017-03-15.

What should I do here to get '2017, Jun 13 2023'? Alternately, I'd be fine removing the partial dates.

Last edited by ownedbycats; 03-22-2024 at 10:04 PM.
ownedbycats is online now   Reply With Quote
Old 03-23-2024, 09:20 AM   #662
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,741
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
format_date and partial dates

I'm using this template to display a list of dates formatted as 'yyyy-MM-dd' as 'MMM d yyyy':

Code:
program:

	new_dates = '';

	for dates in '#datesread':
		converted = format_date(dates, 'MMM d yyyy');
		new_dates = list_union(new_dates, converted, ',')
	rof
However, several entries are just a year; e.g. '2017, 2023-06-13.' When I run them through this template, it ends up filling in the rest of the date so it becomes 2017-03-15.

What should I do here to get '2017, Jun 13 2023'? Alternately, I'd be fine removing the partial dates.
The format_date() function expects a date. A year by itself isn't a date, so calibre's parse_date() makes it into one by using the 15th day of the current month. This isn't going to change.

You don't say if you can have a date like '2020-05'. Assuming you can, a variation of this template might give you what you want.
Code:
program:

	new_dates = '';

	for dates in '2020, 2021-05, 2022-03-10':
		if list_count(dates,'-') ==# 3 then
			converted = format_date(dates, 'MMM d yyyy')
		elif '-' in dates then
			converted = re(format_date(dates, 'MMM d yyyy'), ' 15 ', ' ')
		else
			converted = dates
		fi;
		new_dates = list_union(new_dates, converted, ',')
	rof
It gives the answer
Code:
Mar 10 2022, May 2021, 2020
chaley is offline   Reply With Quote
Old 03-23-2024, 01:20 PM   #663
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,620
Karma: 61176603
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
I have only yyyy and yyyy-mm-dd, but that template worked on all the books I tested.

I didn't think of using a list_count with a - separator.
ownedbycats is online now   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 138 04-23-2024 11:49 AM
[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 05:18 PM.


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