Best way to get the day of a year from month and day of the month?

My problem:
Currently trying to make a seasonal events module which can handle live events for parts of the year (e.g cover roofs with snow meshes when it comes into December and remove them in January)

However to make its UX good im allowing the user to input a month and the day of a month to set the start and end data of the change.

My problem is, in order to allow for easy flexibility with events going over months etc. I need to get the day of the year from this data,


5th of February --> 36

Ideally id also like the system to take leap years into account which has presented me with a multitude of other difficulties.

Any ideas on the best way to go about this?

1 Like

A stackoverflow user answered this:

Please re-read my post, I believe you mis-understood my issue. Im looking to get day of the year from day of the month, not just the present day of the year.

1 Like

Oh shoot, I apologize. I will look into more solutions.

1 Like

@OutlookG was cool and solved it for me. For future reference of those experiencing the problem here is the solution

local StartDay ='%j', os.time({
	year = Year,
	month = Month 
	day = Day}