So, I’m having a hard time calculating the current date based on the Julian calendar. (Julian calendar is a continuous count of days since the beginning of the year. For example, January 1st would be Day “1”, Feb 5th would be Day “36”, Dec 30th would be Day “364”).
The best my non-programming brain could come up with is the following which gets kind of close, but it’s not accurate is: [[(Now.getMonth() * 27) + Now.getDay()]]. Any thoughts to accurately calculate the Julian date based on the current day?
You can do it by using cases. First you need to define variables “month” and “day”. Then, If the month is “1” (January), add nothing to julian day. If it’s “2” (February), add 31 to it, and so on.
I made a small demonstration here (Jan, Feb and Aug months are written as an example):
julian-date.rp (45.2 KB)
You can see the list of julian numbers of each 1st day of each month.
https://www.cdfa.ca.gov/ahfss/mpes/pdfs/Julian_Calendar.pdf
Leap years could be a problem, for that I also added an additional “leap” variable. I divided the year by 4 and calculated if the remaining is “0”. This function outputs “true” or “false”, I needed to change those to “0” and “1”. You’ll get the idea by looking above rp file (page loaded and text loaded actions have the needed code).
Please note that if you’ll use this logic for years in a wide range, please make sure that you calculate end-of-century years a bit differently.
Determining Leap Years
To determine if a year is a leap year, we apply a simple rule: if the year is divisible by 4, it’s a leap year, except for end-of-century years, which must also be divisible by 400. For instance, the year 2000 was a leap year, while 1900 was not.
1 Like
Genius! Thank you so much! This is exactly the logic I needed. I can take it from here