View Single Post
Old 10-21-2024, 06:13 PM   #737
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,488
Karma: 8065348
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
Code:
program:

	readgoal = strcat('readinggoal:', format_date(today(), 'yyyy'));
	challenge =	strcat('rgchallenges:purchases', format_date(today(), 'yyyy'));

	if
		format_date($date, 'yyyy') == format_date(today(), 'yyyy')
		&& readgoal in $#admintags
		&& $#purchasesource
		&& $#cost !='0.00'

	then
		list_union(challenge, $#admintags, ',')
	else
		$#admintags
	fi
Line 7 I'm trying to check whether the book's timestamp/date is set to this year. Is this the best method to do so?
I can't think offhand of a better way without using a python stored template. That said, changing format_date($date, 'yyyy') to format_date_field($date, 'yyyy') will be faster.

EDIT: For consistency with field_list_count() and the new operator field_inlist (addition submitted to Kovid) I submitted a change to rename format_date_field() to field_format_date(). The old name format_date_field() is an alias and will continue to work. My intention is that any new functions and operators that work on fields will be prefixed with 'field_'.

EDIT2: I might reverse the naming convention and put the _field at the end, changing field_list_count() to list_count_field(). The new operator would be inlist_field instead of field_inlist. In this case the format_date_field() wouldn't be renamed. Still thinking ...

Last edited by chaley; 10-21-2024 at 06:51 PM.
chaley is offline   Reply With Quote