Turning a number into a date

Can anybody please help me turn a number variable (which represents the number of days passed since the game started) into a date in the “January 15, 2021” format? Game would start on January 1, 2021, and I have a number variable “day”. Purpose is to have the current date displayed in the status line, so I need a “to say current_date” routine. Any help appreciated! Couldn’t find anything in the documentation.

Yeah, don’t think this is built into Inform, but pretty easy to whip up. Here’s a dummy version (with jumping repurposed to both increment and display the date so you confirm it all works):

Day-number is a number that varies.  Day-number is initially 0.

Report jumping:
	Increment day-number;
	Say "Day number:[day-number][line break]";
	Say "Calendar date:[calendar date]".
	
To say calendar date:
	If day-number is greater than 334:
		say "December [day-number minus 334]";	
	Otherwise if day-number is greater than 304:
		say "November [day-number minus 304]";	
	Otherwise if day-number is greater than 273: 
		say "October [day-number minus 273]";	
	Otherwise if day-number is greater than 243: 
		say "September [day-number minus 243]";	
	Otherwise if day-number is greater than 212: 
		say "August [day-number minus 212]";	
	Otherwise if day-number is greater than 181: 
		say "July [day-number minus 181]";	
	Otherwise if day-number is greater than 151: 
		say "June [day-number minus 151]";	
	Otherwise if day-number is greater than 120: 
		say "May [day-number minus 120]";	
	Otherwise if day-number is greater than 90: 
		say "April [day-number minus 90]";	
	Otherwise if day-number is greater than 59: 
		say "March [day-number minus 59]";
	Otherwise if day-number is greater than 31: 
		say "February [day-number minus 31]";
	Otherwise: 
		say "January [day-number]".
7 Likes

Oh. Yeah well, that did the trick. Thanks!

1 Like