iapt-platform / mint

rewrite of PCD
MIT License
7 stars 15 forks source link

difficulties of Buddhist era #975

Open bhikkhu-kosalla-china opened 2 years ago

bhikkhu-kosalla-china commented 2 years ago

introduction

you can visit this page to use the most accurate buddhist era in the world

for the details of code, can visit code link on github

this article will introduce the details and difficulties of my developing this calendar, I hope it can provide some idea to other developers.

item note
time in single day dawn, noon and sunset is the related to the yogi everyday precept
month named by
lunar mansion nakkhatta
this can show the name of month and important day
year named by zodiac this is srilanka tradition, and the Zodiac order is close to Chinese tradition

dawn and noon time

dawn time

code is very simple but accurate first ,we give the time and space data to date_sun_info function, then we can get the information of the sun in that place and that time grammar date_sun_info(timestamp,latitude,longitude);

$sun_info=date_sun_info(strtotime("now"),7.738562,80.519675);
$Unix_dawn=($sun_info['civil_twilight_begin']-$sun_info['civil_twilight_begin']+$sun_info['nautical_twilight_begin'])*1000;

this is php code, it also realized in JavaScript on the page which can be downloaded and used.

if you are no intested in the procedure, pls ignore the following part.

basic knowledge

the dawn can categorized in 3 kinds:

type angle of sun below the horizon note
Civil dawn 0°~6° civil people can see the object without artificial light source
normally consider as the start of day time
nautical dawn 6°~12° civil people cannot see the object clearly without artificial light source
but on the sea mariners can see objects
Astronomical dawn 12°~18° mariners cannot see the object clearly on the sea
it also show the end/start of Astronomical observing

for the detail can check DAWN in wikipedia

image

how to calculate 6°

according to pāli text, in the dawn time, there is light in 4 directions, that means the civil twilight. So at the starting point, the sun is 6° below the horizon in the morning.

That means dawn time is 6° earlier than sunrise. How long is 6° for the sun pass by? Normally we will think: the sun go 360° is 24 hours,

pass time=24hr/360°×6°=0.4hr=24mins

But we cannot ignore the height of the sun at midday. Only if the height=90°, then the time is 24 mins. That means even the tropical zone, there are only 2 ideal days in one year. For other day, all will be longer than 24 mins. That's why some monastery just minus 30 or 40 mins from the sunrise, it simple but inaccurate.

set α as the height of the sun at midday on one single day,

real-period=24min/sinα

It seemed complicated, right?

but in php, we can find a function called date_sun_info(), grammar:

date_sun_info(timestamp,latitude,longitude);

example:

$sun_info=date_sun_info(strtotime("now"),7.738562,80.519675);
$Unix_dawn=$sun_info['civil_twilight_begin']*1000;

then we can get a array contains 6 kinds of twilight:

advance accurate: astronomical refraction

the deviation of light or other electromagnetic wave from a straight line as it passes through the atmosphere due to the variation in air density as a function of height.

Atmospheric refraction of the light from a star is zero in the zenith, less than 1′ (one arc-minute) at 45° apparent altitude, and still only 5.3′ at 10° altitude; it quickly increases as altitude decreases, reaching 9.9′ at 5° altitude, 18.4′ at 2° altitude, and 35.4′ at the horizon; all values are for 10 °C and 1013.25 hPa in the visible part of the spectrum.

image

35.4′ will cause 3~5 mins earlier.

real-period=35.4‘/60/360×60min/hr×24hr/sinα=2.36min/sinα

Don't worry, even php didn't consider astronomical refraction in civil_twilight_begin, but the sunrise already consider the astronomical refraction,

$sun_info=date_sun_info(strtotime("now"),7.738562,80.519675);
//6° period
$6_period=$sun_info['civil_twilight_begin']-$sun_info['nautical_twilight_begin']
//astronomical refraction
$a_r=$6_period-($sun_info['sunrise']-$sun_info['civil_twilight_begin'])
$real_dawn=$sun_info['civil_twilight_begin']-$a_r

to simplify and change the time stamp for sec into ms final code

//get sun information获取太阳信息
$sun_info=date_sun_info(strtotime("now"),7.738562,80.519675);
//calculating the civil dawn time as unix time stamp(ms), 计算出曙光时间,以unix时间戳计,单位毫秒
$Unix_dawn=($sun_info['civil_twilight_begin']-$sun_info['civil_twilight_begin']+$sun_info['nautical_twilight_begin'])*1000;

noon time

lunar mansion(nakkhatta) and nakshatra month(māsa)

zodiac name of year

the Chinese zodiac and Buddhist era zodiac is very similar the difference is the last day of zodiac year. In Chinese lunar calendar: consider the spring festive eve is the last day and spring festive is the first day. In Buddhist era : consider the vesākha full moon day is the last, and following day is the first day.

EX image

bksubhuti commented 2 years ago

Do you know about Buddhist Sun apk on the play and ios store? It is written in Flutter can can be built for desktop as well, but some functions will not work, like gps and tts on some platforms (like linux). I can maybe update to include calendars as well.