Thread: Imprecise Dates
View Single Post
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,454
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