Sunday, December 1, 2013

XCODE on knees and begged algorithms developed lunar calendar, and to calculate the number of days away from the two days of the Lunar New Algorithm

Beg on the lunar calendar XCODE developed algorithms, and the calculation of the number of days away from the two days of the Lunar
algorithm
Please give a specific code ah! Note the lunar calendar, ah, not calendar to the Gregorian calendar.

- (NSDate *) gongliToNongli: (NSDate *) date
Pass a NSDate Lunar returns the Gregorian

- (Int) getIntervalByNongli: (NSDate *) date1 date: (NSDate *) date2
Incoming two lunar day, a few days away from returning to their

Seeking to write these two functions! ! ! !
Reply:

http://blog.csdn.net/li_guotao/article/details/2280831



1.
Week seeking a formulaWeek = [5 + A (actual days)] mod 7

2.
Lunar formulaSixty Years Lunar number, from 1 -> 59 -> 0.
Sixty Years Lunar number = [23 + A (actual days)] mod 60

3.
Ershibasu formulaErshibasu number = [23 + A (actual days)] mod 28

4 A of the actual number of days calculated
A = B (basic number of days) + C (leap day for a few days)
B = (calculated yr -1) * 365 + (To calculate the number of days to years months days)
Example: Basic number of days B 1984 年 2 January = (1984-1) * 365 + (31 +1) = 723 827 (days),
Among them, 31 to 31 days is January 1 to February 1 to 1 day.
Basic AD 308 Days
August 28,B = (308-1) * 365 + (31 +28 +31 +30 +31 +30 +31 +27) = 112055 +239 = 112294 (day)
Here (To calculate the number of days in the month to date), using the Gregorian calendar, moon day rule the number of days that I
Like the elementary school before. Ha ha ......

C = (Calculation -1) div 4 - error correction value + fixValue2
fixValue2 is 0 or 1. Normally the value is 0, then the number is a leap year (Gregorian leap method) among the March
After the date of 1 1.

Error correction value calculated:
Year the first year January 1 to October 14, 1582 0.
October 15, 1582 to December 31, 1699 is 10.
From January 1, 1701 for each additional accumulate a century, the century of divisible by 400 but not tired
Plus 1. This method can be projected.
- There is a problem, fix the value of 1700 should be the year how much is it? Algorithm just no
Talked about, but it seems it should be 10.

Cases since January 1, 1701 is 11 errors, while January 1, 1801 onwards error correction is 12,
And from January 1, 1901 Error correction is 13,
But in 2001 the error correction value is still 13, because 2000 is divisible by 400, it does not accumulate. The
From 1 January 2101 is 14 error correction.

5 Example: 1998.3.15 week, Lunar and Ershibasu
B = (1998-1) * 365 + (31 +28 +15) = 728979
C = (1998-1) div 4 - 13 + 0 = 486
A = B + C = 728979 +486 = 729465
Week number = (5 +729465) mod 7 = 0, namely Sun
Lunar number = (13 +729465) mod 60 = 58, is yau
Ershibasu number = (23 +729465) mod 28 = 4, is the room

================================================== =
Scary! There are other formulas ...... but it seems not to know how to get some parameters:

Twenty-four post holiday algorithm:
With a known transfer hour plus years of 22 hours 35 minutes, more than 24 to subtract 24 scores foot 60
Into one hour, that cross sections obtained sections 8 years after the hour.
If rainwater cross section 2000 to 16:22 hour, the 2008 cross-section hour rain 14 时 52
Points.
Since 16:22 +22 = 38 when 35 points 57 points. 38-24 = 14.
Who knows year the first year to pay the festival eight years AD, the algorithm can be achieved. - Good
Like the inverse algorithm can solve this problem. Who try?

Lunar leap month algorithms:
Lunar New Year in twenty-four solar terms (twelve and twelve solar terms in gas) in the air in late fall, the next
Months, there is no in gas. This will have the Lunar Festival (throttle) no gas (in air) is defined as a leap month
Months. On average, there are seven leap months for 19 years.
But the 24 solar terms in the twelve gas throttle and twelve is how to divide it? I have no information,
Estimate for should be a throttle a cross in the air like this. : (
Reply:
cited a floor reply:
http://blog.csdn.net/li_guotao/article/details/2280831



1.
Week seeking a formulaWeek = [5 + A (actual days)] mod 7

2.
Lunar formulaSixty Years Lunar number, from 1 -> 59 -> 0.
Sixty Years Lunar number = [23 + A (actual days)] mod 60

3.
Ershibasu formulaErshibasu number = [23 + A (actual days)] mod 2 ......


You that useless, give me the code directly which of the two functions ah!
Reply:
You that post useless ah, please give my two functions directly code!
Reply:
The reply was deleted on 2012-07-13 09:46:02 moderator

No comments:

Post a Comment