Calculating Julian dates Refactor this code so that I don't have to insert the parameters any time I need to use one of the functions.

I have a class, say julian, for calculating Julian dates of today, a date I insert and the difference between these two Julian dates. 

        int julian::calc_julianToday()
        {
            time_t t = time(0);
            struct tm *now = localtime( &amp;t );
                todDay = now-&gt;tm_mday;
                todMonth = now-&gt;tm_mon+1;
                todYear = now-&gt;tm_year+1900;

              int at = (14 - todMonth) / 12;
              int yt = todYear + 4800 - at;
              int mt = todMonth + 12 * at - 3;
              if (todYear &gt; 1582 || (todYear == 1582 &amp;&amp; todMonth &gt; 10) || 
    (todYear == 1582 &amp;&amp; todMonth == 10 &amp;&amp; todDay &gt;= 15))
                return julToday =  todDay + (153 * mt + 2) / 5 + 365 * yt 
    + yt / 4 - yt / 100 + yt / 400 - 32045;
              else
                return julToday = todDay + (153 * mt + 2) / 5 + 365 * yt + yt / 4 - 32083;

        }
        int julian::calc_juliandate(int day, int month, int year)
        {

              int a = (14 - month) / 12;
              int y = year + 4800 - a;
              int m = month + 12 * a - 3;
              if (year &gt; 1582 || (year == 1582 &amp;&amp; month &gt; 10) || 
(year == 1582 &amp;&amp; month == 10 &amp;&amp; day &gt;= 15))
                return julStart = day + (153 * m + 2) / 5 
    + 365 * y + y / 4 - y / 100 + y / 400 - 32045;
              else
                return julStart = day + (153 * m + 2) / 5 + 365 * y + y / 4 - 32083;

        }

        int julian::dates_diff(int day, int month, int year)
        {
            int start = calcJulStartDate(day, month, year);
            int today = calcJulTodayDate();
            differ = today-start;
            return differ;
        }


Please note that all the variable types are declared in a header file. What I would like to do in main() is to be able to use calc_juliandate() without having to call it and pass its attributes each and every time I need it in another function, as in dates_diff().
Any suggestions about coding style or implementing this?
Welcome to Code Review,

I do not know how to solve your problem, however, your code could use polishing.


Magical constants; your code is littered with them, use constants instead
Undocumented magical constants, I can guess what 365 or 12 is used for, other constants like 32083 could use a comment or could show the calculation of how you got there
Naming; todDay, todMonth and todYear are terrible names
Naming; at, ty and mt are even worse
Casing; be consistent, you mix underscores with casing and even your casing is not consistent ( calc_julianToday &lt;> calc_juliandate )
Indenting! Your indenting is all over the place and distracts the reader
Repeating / DRY;


I do not write C++ but can you not write calc_julianToday() as

int julian::calc_julianToday()
{
  time_t t = time(0);
  struct tm *now = localtime( &amp;t );
  return julToday =  calc_juliandate( now-&gt;tm_mday, now-&gt;tm_mon+1, now-&gt;tm_year+1900 ) ;  
}