View Single Post
Old 06-02-2021, 10:26 AM   #15
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,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by un_pogaz View Post
small error in
Code:
# Convert the timestamp back into a datte
	end_ts = format_date(start_ts, 'from_number');
Use end_ts instead of start_ts
Thanks for that.

There is an optimization available. 'from_number' also accepts the date format, so you can use:
Code:
# Convert the timestamp back into a datte
# Format the date as desired
	format_date(end_ts, 'from_number:yyyy MM dd')
Here is the entire template with un_pogaz's correction and the optimization
Code:
program:
# Calculate number of seconds in a day
	one_day = 60 * 60 * 24;
# Calculate total seconds for days of loan
	loan_seconds = one_day * $#diasadevolver;
# Get the start date in ISO format
	start_day = $$#fechaprestamo;
# Get the "timestamp" for the start date -- number of seconds since epoch
	start_ts = format_date(start_day, 'to_number');
# Add the number of seconds for the days of loan	
	end_ts = start_ts + loan_seconds;
# Convert the timestamp back into a date
# Format the date as desired
	format_date(end_ts, 'from_number:yyyy MM dd');
chaley is offline   Reply With Quote