33
44#include  < cmath> 
55
6- class  bikram  {
6+ class  Bikram  {
77private: 
88    int  Year = 0 ;
99    int  Month = -1 ;
1010    int  Day = 0 ;
1111
1212    double  YugaRotation_star = 1582237828 ;
1313    double  YugaRotation_sun = 4320000 ;
14-     double  YugaCivilDays; 
15-     double  PlanetApogee_sun = 77  + static_cast < float >( 17 )  / 60 ;
16-     double  PlanetCircumm_sun = 13  + static_cast < float >( 50 )  / 60 ;
14+     double  YugaCivilDays = YugaRotation_star - YugaRotation_sun;  //  Initialize here 
15+     double  PlanetApogee_sun = 77  + 17.0  / 60 ;  //  Use double for division 
16+     double  PlanetCircumm_sun = 13  + 50.0  / 60 ;  //  Use double for division 
1717    static  constexpr  double  rad = 57.2957795 ; //  180 / pi
1818
19-     void  get_saura_masa_day (long  ahar, int * m, int * d) const ;
20-     int  today_saura_masa_first_p (long  ahar) const ;
21-     double  get_tslong (long  ahar) const ;
22-     double  get_julian_date (int  year, int  month, int  day) const ;
19+     void  getSauraMasaDay (long  ahar, int * m, int * d) const ;
20+     int  todaySauraMasaFirstP (long  ahar) const ;
21+     double  getTslong (long  ahar) const ;
22+     double  getJulianDate (int  year, int  month, int  day) const ;
2323    void  fromJulianDate (double  julian_date, int & year, int & month, int & day) const ;
2424
2525public: 
@@ -31,32 +31,32 @@ class bikram {
3131    int  daysInMonth (int  year, int  month);
3232};
3333
34- inline  void  bikram::get_saura_masa_day (long  ahar, int * m, int * d) const  {
34+ inline  void  Bikram::getSauraMasaDay (long  ahar, int * m, int * d) const  {
3535    double  tslong_tomorrow;
3636    int  month;
3737    int  day;
38-     if  (today_saura_masa_first_p (ahar)) {
38+     if  (todaySauraMasaFirstP (ahar)) {
3939        day = 1 ;
40-         tslong_tomorrow = get_tslong (ahar + 1 );
41-         month = ( long ) (tslong_tomorrow / 30 ) % 12 ;
40+         tslong_tomorrow = getTslong (ahar + 1 );
41+         month = static_cast < int > (tslong_tomorrow / 30 ) % 12 ;
4242        month = (month + 12 ) % 12 ;
4343    } else  {
44-         get_saura_masa_day (ahar - 1 , &month, &day);
44+         getSauraMasaDay (ahar - 1 , &month, &day);
4545        day += 1 ;
4646    }
4747    *m = month;
4848    *d = day;
4949}
5050
51- inline  int  bikram::today_saura_masa_first_p (long  ahar) const  {
52-     double  tslong_today = get_tslong (ahar);
53-     double  tslong_tomorrow = get_tslong (ahar + 1 );
54-     tslong_today = tslong_today - ( int ) (tslong_today / 30 ) * 30 ;
55-     tslong_tomorrow = tslong_tomorrow - ( int ) (tslong_tomorrow / 30 ) * 30 ;
56-     return  (25  < tslong_today)  && ( tslong_tomorrow < 5 ) ? 1  : 0 ;
51+ inline  int  Bikram::todaySauraMasaFirstP (long  ahar) const  {
52+     double  tslong_today = getTslong (ahar);
53+     double  tslong_tomorrow = getTslong (ahar + 1 );
54+     tslong_today -=  static_cast < int > (tslong_today / 30 ) * 30 ;
55+     tslong_tomorrow -=  static_cast < int > (tslong_tomorrow / 30 ) * 30 ;
56+     return  (25  < tslong_today && tslong_tomorrow < 5 ) ? 1  : 0 ;
5757}
5858
59- inline  double  bikram::get_tslong (long  ahar) const  {
59+ inline  double  Bikram::getTslong (long  ahar) const  {
6060    double  mslong;
6161    double  t1 = (YugaRotation_sun * ahar / YugaCivilDays);
6262    t1 -= static_cast <long >(t1);
@@ -70,17 +70,17 @@ inline double bikram::get_tslong(long ahar) const {
7070    return  x3;
7171}
7272
73- inline  double  bikram::get_julian_date (int  year, int  month, int  day) const  {
73+ inline  double  Bikram::getJulianDate (int  year, int  month, int  day) const  {
7474    if  (month <= 2 ) {
7575        year -= 1 ;
7676        month += 12 ;
7777    }
7878    double  a = floor (year / 100.0 );
7979    double  b = 2  - a + floor (a / 4.0 );
80-     return  floor (365.25  * (year + 4716 )) + floor (30.6001  * (month + 1 )) + day + b - 1524.5 ;
80+     return  floor   (365.25  * (year + 4716 )) + floor (30.6001  * (month + 1 )) + day + b - 1524.5 ;
8181}
8282
83- inline  void  bikram ::fromJulianDatedouble  julian_date, int & year, int & month, int & day) const  {
83+ inline  void  Bikram ::fromJulianDatedouble  julian_date, int & year, int & month, int & day) const  {
8484    int  a = static_cast <int >(julian_date + 0.5 );
8585    int  b = a + 1537 ;
8686    int  c = static_cast <int >((b - 122.1 ) / 365.25 );
@@ -92,13 +92,12 @@ inline void bikram::fromJulianDate(double julian_date, int& year, int& month, in
9292    year = (month > 2 ) ? (c - 4716 ) : (c - 4715 );
9393}
9494
95- inline  void  bikram::fromGregorian (int  y, int  m, int  d) {
96-     YugaCivilDays = YugaRotation_star - YugaRotation_sun;
97-     double  julian = get_julian_date (y, m, d);
95+ inline  void  Bikram::fromGregorian (int  y, int  m, int  d) {
96+     double  julian = getJulianDate (y, m, d);
9897    long  ahar = julian - 588465.5 ;
9998    int  saura_masa_num;
10099    int  saura_masa_day;
101-     get_saura_masa_day (ahar, &saura_masa_num, &saura_masa_day);
100+     getSauraMasaDay (ahar, &saura_masa_num, &saura_masa_day);
102101    long  YearKali = static_cast <long >(ahar * YugaRotation_sun / YugaCivilDays);
103102    int  YearSaka = YearKali - 3179 ;
104103    int  nepalimonth = (saura_masa_num) % 12 ;
@@ -107,42 +106,41 @@ inline void bikram::fromGregorian(int y, int m, int d) {
107106    Day = saura_masa_day;
108107}
109108
110- inline  void  bikram::toGregorian (int  bsYear, int  bsMonth, int  bsDay, int & gYear , int & gMonth , int & gDay ) {
111-     YugaCivilDays = YugaRotation_star - YugaRotation_sun;
109+ inline  void  Bikram::toGregorian (int  bsYear, int  bsMonth, int  bsDay, int & gYear , int & gMonth , int & gDay ) {
112110    int  YearSaka = bsYear - 135 ;
113111    long  YearKali = YearSaka + 3179 ;
114112    long  ahar = static_cast <long >((YearKali * YugaCivilDays) / YugaRotation_sun);
115113    int  saura_masa_num, saura_masa_day;
116-     get_saura_masa_day (ahar, &saura_masa_num, &saura_masa_day);
114+     getSauraMasaDay (ahar, &saura_masa_num, &saura_masa_day);
117115    bsMonth = (bsMonth + 11 ) % 12 ;
118116    while  (saura_masa_num != bsMonth || saura_masa_day != bsDay) {
119117        ahar += (saura_masa_num < bsMonth || (saura_masa_num == bsMonth && saura_masa_day < bsDay)) ? 1  : -1 ;
120-         get_saura_masa_day (ahar, &saura_masa_num, &saura_masa_day);
118+         getSauraMasaDay (ahar, &saura_masa_num, &saura_masa_day);
121119    }
122120    double  julian_date = ahar + 588465.5 ;
123121    fromJulianDate (julian_date, gYear , gMonth , gDay );
124122}
125123
126- inline  int  bikram ::getYearconst  {
124+ inline  int  Bikram ::getYearconst  {
127125    return  Year;
128126}
129127
130- inline  int  bikram ::getMonthconst  {
128+ inline  int  Bikram ::getMonthconst  {
131129    return  Month + 1 ;
132130}
133131
134- inline  int  bikram ::getDayconst  {
132+ inline  int  Bikram ::getDayconst  {
135133    return  Day;
136134}
137135
138- inline  int  bikram ::daysInMonthint  bsYear, int  bsMonth)   {
136+ inline  int  Bikram ::daysInMonthint  bsYear, int  bsMonth) {
139137    int  gYear , gMonth , gDay ;
140138    int  nextMonth = (bsMonth % 12 ) + 1 ;
141139    int  nextYear = (bsMonth == 12 ) ? bsYear + 1  : bsYear;
142140    toGregorian (bsYear, bsMonth, 1 , gYear , gMonth , gDay );
143-     double  julian_date_start = get_julian_date (gYear , gMonth , gDay );
141+     double  julian_date_start = getJulianDate (gYear , gMonth , gDay );
144142    toGregorian (nextYear, nextMonth, 1 , gYear , gMonth , gDay );
145-     double  julian_date_end = get_julian_date (gYear , gMonth , gDay );
143+     double  julian_date_end = getJulianDate (gYear , gMonth , gDay );
146144    return  static_cast <int >(julian_date_end - julian_date_start);
147145}
148146
0 commit comments