Skip to content

Commit

Permalink
update code, widen varibles range
Browse files Browse the repository at this point in the history
  • Loading branch information
vantoan8x committed Jun 30, 2013
1 parent f869a69 commit 84fc0c9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
3 changes: 3 additions & 0 deletions SunLunar.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,7 @@ typedef struct
// Get Lunar Previous Day from Lunar day
- (TimeSL) getLunarPreviousDay:(int)day month:(int)month year:(int)year;

// Get Leap From Sun Date
- (int) getLunarLeapFromSunDate:(int)day month:(int)month year:(int)year timeZone:(int)timeZone;

@end
22 changes: 11 additions & 11 deletions SunLunar.m
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,9 @@ - (int) getLocalTimeZoneNumber
return tz;
}

- (int) jdFromDate:(int)day month:(int)month year:(int)year
- (long) jdFromDate:(int)day month:(int)month year:(int)year
{
int a, y, m, jd;
long a, y, m, jd;

a = ((14 - month) / 12);
y = year + 4800 - a;
Expand All @@ -338,15 +338,15 @@ - (int) jdFromDate:(int)day month:(int)month year:(int)year
return jd;
}

- (TimeSL)jdToDate:(long long)jd
- (TimeSL)jdToDate:(long)jd
{
long long a, b, c, d, e, m, day, month, year;
long a, b, c, d, e, m, day, month, year;

if (jd > 2299160)
{ // After 5/10/1582, Gregorian calendarr
a = jd + 32044;
b = (int)((4*a+3)/146097);
c = a - (int)((b*146097)/4);
b = (int)((4*a+3)/146097.0);
c = a - (int)((b*146097)/4.0);
}
else
{
Expand Down Expand Up @@ -402,7 +402,7 @@ - (int) getNewMoonDay:(CGFloat)k timeZone:(int)timeZone

- (int) getSunLongitude:(CGFloat)jdn timeZone:(int)timeZone
{
CGFloat T, T2, dr, M, L0, DL, L;
double T, T2, dr, M, L0, DL, L;

T = (jdn - 2451545.5 - timeZone/24.0) / 36525; // Time in Julian centuries from 2000-01-01 12:00:00 GMT
T2 = T*T;
Expand Down Expand Up @@ -456,7 +456,7 @@ - (int) getLeapMonthOffset:(CGFloat)a11 timeZone:(int)timeZone

- (int) getLunarLeapFromSunDate:(int)day month:(int)month year:(int)year timeZone:(int)timeZone
{
CGFloat k, dayNumber, monthStart, a11, b11, lunarLeap;
long k, dayNumber, monthStart, a11, b11, lunarLeap;

dayNumber = [self jdFromDate:day month:month year:year];

Expand Down Expand Up @@ -492,7 +492,7 @@ - (int) getLunarLeapFromSunDate:(int)day month:(int)month year:(int)year timeZon
}
}

return lunarLeap;
return (int)lunarLeap;
}

- (TimeSL) convertSunToLunar:(TimeSL)date timeZone:(int)timeZone
Expand All @@ -503,7 +503,7 @@ - (TimeSL) convertSunToLunar:(TimeSL)date timeZone:(int)timeZone
- (TimeSL) convertSunToLunar:(int)day month:(int)month year:(int)year timeZone:(int)timeZone
{

int k, dayNumber, monthStart, a11, b11, lunarDay, lunarMonth, lunarYear, lunarLeap;
long k, dayNumber, monthStart, a11, b11, lunarDay, lunarMonth, lunarYear, lunarLeap;

dayNumber = [self jdFromDate:day month:month year:year];

Expand Down Expand Up @@ -567,7 +567,7 @@ - (TimeSL) convertLunarToSun:(TimeSL)date timeZone:(int)timeZone
- (TimeSL) convertLunarToSun:(int)day month:(int)month year:(int)year lunarLeap:(int)lunarLeap timeZone:(int)timeZone
{

CGFloat k, a11, b11, off, leapOff, leapMonth, monthStart;
long k, a11, b11, off, leapOff, leapMonth, monthStart;
if (month < 11)
{
a11 = [self getLunarMonth11:year-1 timeZone:timeZone];
Expand Down

0 comments on commit 84fc0c9

Please sign in to comment.