首先创建一个农历文件

LunarCalendar.h

 //
// LunarCalendar.h
// Hnair4iPhone
//
// Created by yingkong1987 on 13-10-10.
// Copyright (c) 2013年 yingkong1987. All rights reserved.
// #import <Foundation/Foundation.h> struct SolarTerm
{
__unsafe_unretained NSString *solarName;
int solarDate;
}; @interface LunarCalendar : NSObject
{
NSArray *HeavenlyStems;
NSArray *EarthlyBranches;
NSArray *LunarZodiac;
NSArray *SolarTerms;
NSArray *arrayMonth;
NSArray *arrayDay; NSDate *thisdate; int year;
int month;
int day; int lunarYear; //农历年
int lunarMonth; //农历月
int doubleMonth; //闰月
bool isLeap; //是否闰月标记
int lunarDay; //农历日 struct SolarTerm solarTerm[]; NSString *yearHeavenlyStem;
NSString *monthHeavenlyStem;
NSString *dayHeavenlyStem; NSString *yearEarthlyBranch;
NSString *monthEarthlyBranch;
NSString *dayEarthlyBranch; NSString *monthLunar;
NSString *dayLunar; NSString *zodiacLunar; NSString *solarTermTitle;
} -(void)loadWithDate:(NSDate *)date; -(void)InitializeValue;
-(int)LunarYearDays:(int)y;
-(int)DoubleMonth:(int)y;
-(int)DoubleMonthDays:(int)y;
-(int)MonthDays:(int)y :(int)m;
-(void)ComputeSolarTerm; -(double)Term:(int)y :(int)n :(bool)pd;
-(double)AntiDayDifference:(int)y :(double)x;
-(double)EquivalentStandardDay:(int)y :(int)m :(int)d;
-(int)IfGregorian:(int)y :(int)m :(int)d :(int)opt;
-(int)DayDifference:(int)y :(int)m :(int)d;
-(double)Tail:(double)x; -(NSString *)MonthLunar;
-(NSString *)DayLunar;
-(NSString *)ZodiacLunar;
-(NSString *)YearHeavenlyStem;
-(NSString *)MonthHeavenlyStem;
-(NSString *)DayHeavenlyStem;
-(NSString *)YearEarthlyBranch;
-(NSString *)MonthEarthlyBranch;
-(NSString *)DayEarthlyBranch;
-(NSString *)SolarTermTitle;
-(bool)IsLeap;
-(int)GregorianYear;
-(int)GregorianMonth;
-(int)GregorianDay;
-(int)Weekday;
-(NSString *)Constellation; @end @interface NSDate (LunarCalendar) /****************************************************
*@Description:获得NSDate对应的中国日历(农历)的NSDate
*@Params:nil
*@Return:NSDate对应的中国日历(农历)的LunarCalendar
****************************************************/
- (LunarCalendar *)chineseCalendarDate; @end

LunarCalendar.m

 //
// LunarCalendar.m
// Hnair4iPhone
//
// Created by yingkong1987 on 13-10-10.
// Copyright (c) 2013年 yingkong1987. All rights reserved.
// #import "LunarCalendar.h" int LunarCalendarInfo[] = { 0x04bd8,0x04ae0,0x0a570,0x054d5,0x0d260,0x0d950,0x16554,0x056a0,0x09ad0,0x055d2,
0x04ae0,0x0a5b6,0x0a4d0,0x0d250,0x1d255,0x0b540,0x0d6a0,0x0ada2,0x095b0,0x14977,
0x04970,0x0a4b0,0x0b4b5,0x06a50,0x06d40,0x1ab54,0x02b60,0x09570,0x052f2,0x04970,
0x06566,0x0d4a0,0x0ea50,0x06e95,0x05ad0,0x02b60,0x186e3,0x092e0,0x1c8d7,0x0c950,
0x0d4a0,0x1d8a6,0x0b550,0x056a0,0x1a5b4,0x025d0,0x092d0,0x0d2b2,0x0a950,0x0b557,
0x06ca0,0x0b550,0x15355,0x04da0,0x0a5b0,0x14573,0x052b0,0x0a9a8,0x0e950,0x06aa0,
0x0aea6,0x0ab50,0x04b60,0x0aae4,0x0a570,0x05260,0x0f263,0x0d950,0x05b57,0x056a0,
0x096d0,0x04dd5,0x04ad0,0x0a4d0,0x0d4d4,0x0d250,0x0d558,0x0b540,0x0b6a0,0x195a6,
0x095b0,0x049b0,0x0a974,0x0a4b0,0x0b27a,0x06a50,0x06d40,0x0af46,0x0ab60,0x09570,
0x04af5,0x04970,0x064b0,0x074a3,0x0ea50,0x06b58,0x055c0,0x0ab60,0x096d5,0x092e0,
0x0c960,0x0d954,0x0d4a0,0x0da50,0x07552,0x056a0,0x0abb7,0x025d0,0x092d0,0x0cab5,
0x0a950,0x0b4a0,0x0baa4,0x0ad50,0x055d9,0x04ba0,0x0a5b0,0x15176,0x052b0,0x0a930,
0x07954,0x06aa0,0x0ad50,0x05b52,0x04b60,0x0a6e6,0x0a4e0,0x0d260,0x0ea65,0x0d530,
0x05aa0,0x076a3,0x096d0,0x04bd7,0x04ad0,0x0a4d0,0x1d0b6,0x0d250,0x0d520,0x0dd45,
0x0b5a0,0x056d0,0x055b2,0x049b0,0x0a577,0x0a4b0,0x0aa50,0x1b255,0x06d20,0x0ada0,
0x14b63}; @implementation LunarCalendar -(id)init
{
HeavenlyStems = [NSArray arrayWithObjects:@"甲",@"乙",@"丙",@"丁",@"戊",@"己",@"庚",@"辛",@"壬",@"癸",nil];
EarthlyBranches = [NSArray arrayWithObjects:@"子",@"丑",@"寅",@"卯",@"辰",@"巳",@"午",@"未",@"申",@"酉",@"戌",@"亥",nil];
LunarZodiac = [NSArray arrayWithObjects:@"鼠",@"牛",@"虎",@"兔",@"龙",@"蛇",@"马",@"羊",@"猴",@"鸡",@"狗",@"猪",nil]; SolarTerms = [NSArray arrayWithObjects:@"立春", @"雨水", @"惊蛰", @"春分", @"清明", @"谷雨", @"立夏", @"小满", @"芒种", @"夏至", @"小暑", @"大暑", @"立秋", @"处暑", @"白露", @"秋分", @"寒露", @"霜降", @"立冬", @"小雪", @"大雪", @"冬至", @"小寒", @"大寒", nil]; arrayMonth = [NSArray arrayWithObjects:@"正月", @"二月", @"三月", @"四月", @"五月", @"六月", @"七月", @"八月", @"九月", @"十月", @"冬月", @"腊月", nil]; arrayDay = [NSArray arrayWithObjects:@"初一", @"初二", @"初三", @"初四", @"初五", @"初六", @"初七", @"初八", @"初九", @"初十", @"十一", @"十二", @"十三", @"十四", @"十五", @"十六", @"十七", @"十八", @"十九", @"二十", @"廿一", @"廿二", @"廿三", @"廿四", @"廿五", @"廿六", @"廿七", @"廿八", @"廿九", @"三十", @"三一", nil]; return self;
} -(void)loadWithDate:(NSDate *)adate
{
if (adate == nil)
[self loadWithDate:[NSDate date]];
else
{
HeavenlyStems = [NSArray arrayWithObjects:@"甲",@"乙",@"丙",@"丁",@"戊",@"己",@"庚",@"辛",@"壬",@"癸",nil];
EarthlyBranches = [NSArray arrayWithObjects:@"子",@"丑",@"寅",@"卯",@"辰",@"巳",@"午",@"未",@"申",@"酉",@"戌",@"亥",nil];
LunarZodiac = [NSArray arrayWithObjects:@"鼠",@"牛",@"虎",@"兔",@"龙",@"蛇",@"马",@"羊",@"猴",@"鸡",@"狗",@"猪",nil]; SolarTerms = [NSArray arrayWithObjects:@"立春", @"雨水", @"惊蛰", @"春分", @"清明", @"谷雨", @"立夏", @"小满", @"芒种", @"夏至", @"小暑", @"大暑", @"立秋", @"处暑", @"白露", @"秋分", @"寒露", @"霜降", @"立冬", @"小雪", @"大雪", @"冬至", @"小寒", @"大寒", nil]; arrayMonth = [NSArray arrayWithObjects:@"正月", @"二月", @"三月", @"四月", @"五月", @"六月", @"七月", @"八月", @"九月", @"十月", @"冬月", @"腊月", nil]; arrayDay = [NSArray arrayWithObjects:@"初一", @"初二", @"初三", @"初四", @"初五", @"初六", @"初七", @"初八", @"初九", @"初十", @"十一", @"十二", @"十三", @"十四", @"十五", @"十六", @"十七", @"十八", @"十九", @"二十", @"廿一", @"廿二", @"廿三", @"廿四", @"廿五", @"廿六", @"廿七", @"廿八", @"廿九", @"三十", @"三一", nil]; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateStyle:NSDateFormatterMediumStyle];
[dateFormatter setTimeStyle:NSDateFormatterNoStyle]; [dateFormatter setDateFormat:@"yyyy"];
year = [[dateFormatter stringFromDate:adate] intValue]; [dateFormatter setDateFormat:@"MM"];
month = [[dateFormatter stringFromDate:adate] intValue]; [dateFormatter setDateFormat:@"dd"];
day = [[dateFormatter stringFromDate:adate] intValue]; thisdate = adate;
}
} -(void)InitializeValue
{
NSString *start = @"1900-01-31";
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd"];
NSString *end = [dateFormatter stringFromDate:thisdate]; NSDateFormatter *f = [[NSDateFormatter alloc] init];
[f setDateFormat:@"yyyy-MM-dd"];
NSDate *startDate = [f dateFromString:start];
NSDate *endDate = [f dateFromString:end]; NSCalendar *gregorianCalendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *components = [gregorianCalendar components:NSDayCalendarUnit fromDate:startDate toDate:endDate options:]; int dayCyclical=(([components day] + )/(/(*)))+; int sumdays = [components day]; int tempdays = ; //计算农历年
for (lunarYear = ; lunarYear < && sumdays > ; lunarYear++)
{
tempdays = [self LunarYearDays:lunarYear];
sumdays -= tempdays;
} if (sumdays < )
{
sumdays += tempdays;
lunarYear--;
} //计算闰月
doubleMonth = [self DoubleMonth:lunarYear];
isLeap = false; //计算农历月
for (lunarMonth = ; lunarMonth < && sumdays > ; lunarMonth++)
{
//闰月
if (doubleMonth > && lunarMonth == (doubleMonth + ) && isLeap == false)
{
--lunarMonth;
isLeap = true;
tempdays = [self DoubleMonthDays:lunarYear];
}
else
{
tempdays = [self MonthDays:lunarYear:lunarMonth];
} //解除闰月
if (isLeap == true && lunarMonth == (doubleMonth + ))
{
isLeap = false;
}
sumdays -= tempdays;
} //计算农历日
if (sumdays == && doubleMonth > && lunarMonth == doubleMonth + )
{
if (isLeap)
{
isLeap = false;
}
else
{
isLeap = true;
--lunarMonth;
}
} if (sumdays < )
{
sumdays += tempdays;
--lunarMonth;
} lunarDay = sumdays + ; //计算节气
[self ComputeSolarTerm]; solarTermTitle = @"";
for (int i=; i<; i++)
{
NSDateFormatter *currentFormatter = [[NSDateFormatter alloc] init]; [currentFormatter setDateFormat:@"yyyyMMdd"]; if (solarTerm[i].solarDate == [[currentFormatter stringFromDate:thisdate] intValue])
solarTermTitle = solarTerm[i].solarName;
} monthLunar = (NSString *)[arrayMonth objectAtIndex:(lunarMonth - )];
dayLunar = (NSString *)[arrayDay objectAtIndex:(lunarDay - )];
zodiacLunar = (NSString *)[LunarZodiac objectAtIndex:((lunarYear - ) % % )]; yearHeavenlyStem = (NSString *)[HeavenlyStems objectAtIndex:((lunarYear - ) % % )];
if ((((year-)*+month+)%) == )
monthHeavenlyStem = (NSString *)[HeavenlyStems objectAtIndex:];
else
monthHeavenlyStem = (NSString *)[HeavenlyStems objectAtIndex:(((year-)*+month+)%-)]; dayHeavenlyStem = (NSString *)[HeavenlyStems objectAtIndex:(dayCyclical%)]; yearEarthlyBranch = (NSString *)[EarthlyBranches objectAtIndex:((lunarYear - ) % % )];
if ((((year-)*+month+)%) == )
monthEarthlyBranch = (NSString *)[EarthlyBranches objectAtIndex:];
else
monthEarthlyBranch = (NSString *)[EarthlyBranches objectAtIndex:(((year-)*+month+)%-)];
dayEarthlyBranch = (NSString *)[EarthlyBranches objectAtIndex:(dayCyclical%)];
} -(int)LunarYearDays:(int)y
{
int i, sum = ;
for (i = 0x8000; i > 0x8; i >>= )
{
if ((LunarCalendarInfo[y - ] & i) != )
sum += ;
}
return (sum + [self DoubleMonthDays:y]);
} -(int)DoubleMonth:(int)y
{
return (LunarCalendarInfo[y - ] & 0xf);
} ///返回农历年闰月的天数
-(int)DoubleMonthDays:(int)y
{
if ([self DoubleMonth:y] != )
return (((LunarCalendarInfo[y - ] & 0x10000) != ) ? : );
else
return ();
} ///返回农历年月份的总天数
-(int)MonthDays:(int)y :(int)m
{
return (((LunarCalendarInfo[y - ] & (0x10000 >> m)) != ) ? : );
} -(void)ComputeSolarTerm
{
for (int n = month * - ; n <= month * ; n++)
{
double Termdays = [self Term:year:n:YES];
double mdays = [self AntiDayDifference:year:floor(Termdays)];
//double sm1 = floor(mdays / 100);
int hour = (int)floor((double)[self Tail:Termdays] * );
int minute = (int)floor((double)([self Tail:Termdays] * - hour) * );
int tMonth = (int)ceil((double)n / );
int tday = (int)mdays % ; if (n >= )
solarTerm[n - month * + ].solarName = [SolarTerms objectAtIndex:(n - )];
else
solarTerm[n - month * + ].solarName = [SolarTerms objectAtIndex:(n + )]; NSDateComponents *components = [[NSDateComponents alloc] init];
[components setYear:year];
[components setMonth:tMonth];
[components setDay:tday];
[components setHour:hour];
[components setMinute:minute]; NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDate *ldate = [gregorian dateFromComponents:components]; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:@"yyyyMMdd"]; solarTerm[n - month * + ].solarDate = [[dateFormatter stringFromDate:ldate] intValue];
}
} -(double)Tail:(double)x
{
return x - floor(x);
} -(double)Term:(int)y :(int)n :(bool)pd
{
//儒略日
double juD = y * (365.2423112 - 6.4e-14 * (y - ) * (y - ) - 3.047e-8 * (y - )) + 15.218427 * n + 1721050.71301; //角度
double tht = 3e- * y - 0.372781384 - 0.2617913325 * n; //年差实均数
double yrD = (1.945 * sin(tht) - 0.01206 * sin( * tht)) * (1.048994 - 2.583e-5 * y); //朔差实均数
double shuoD = -18e- * sin(2.313908653 * y - 0.439822951 - 3.0443 * n); double vs = (pd) ? (juD + yrD + shuoD - [self EquivalentStandardDay:y::] - ) : (juD - [self EquivalentStandardDay:y::] - );
return vs;
} -(double)AntiDayDifference:(int)y :(double)x
{
int m = ;
for (int j = ; j <= ; j++)
{
int mL = [self DayDifference:y:(j+):] - [self DayDifference:y:j:];
if (x <= mL || j == )
{
m = j;
break;
}
else
x -= mL;
}
return * m + x;
} -(double)EquivalentStandardDay:(int)y :(int)m :(int)d
{
//Julian的等效标准天数
double v = (y - ) * + floor((double)((y - ) / )) + [self DayDifference:y:m:d] - ; if (y > )
{//Gregorian的等效标准天数
v += -floor((double)((y - ) / )) + floor((double)((y - ) / )) + ;
}
return v;
} -(int)DayDifference:(int)y :(int)m :(int)d
{
int ifG = [self IfGregorian:y:m:d:];
//NSArray *monL = [NSArray arrayWithObjects:, nil];
NSInteger monL[] = {, , , , , , , , , , , , };
if (ifG == )
{
if ((y % != && y % == ) || (y % == ))
monL[] += ;
else
{
if (y % == )
monL[] += ;
}
} int v = ; for (int i = ; i <= m - ; i++)
v += monL[i]; v += d;
if (y == )
{
if (ifG == )
v -= ;
if (ifG == -)
v = ; //infinity
}
return v;
} -(int)IfGregorian:(int)y :(int)m :(int)d :(int)opt
{
if (opt == )
{
if (y > || (y == && m > ) || (y == && m == && d > ))
return (); //Gregorian
else
if (y == && m == && d >= && d <= )
return (-); //空
else
return (); //Julian
} if (opt == )
return (); //Gregorian
if (opt == )
return (); //Julian
return (-);
} -(NSString *)MonthLunar
{
return monthLunar;
} -(NSString *)DayLunar
{
return dayLunar;
} -(NSString *)ZodiacLunar
{
return zodiacLunar;
} -(NSString *)YearHeavenlyStem
{
return yearHeavenlyStem;
} -(NSString *)MonthHeavenlyStem
{
return monthHeavenlyStem;
} -(NSString *)DayHeavenlyStem
{
return dayHeavenlyStem;
} -(NSString *)YearEarthlyBranch
{
return yearEarthlyBranch;
} -(NSString *)MonthEarthlyBranch
{
return monthEarthlyBranch;
} -(NSString *)DayEarthlyBranch
{
return dayEarthlyBranch;
} -(NSString *)SolarTermTitle
{
return solarTermTitle;
} -(bool)IsLeap
{
return isLeap;
} -(int)GregorianYear
{
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"yyyy"];
int ret = [[formatter stringFromDate:thisdate] intValue]; return ret;
} -(int)GregorianMonth
{
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"MM"];
int ret = [[formatter stringFromDate:thisdate] intValue]; return ret;
} -(int)GregorianDay
{
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"dd"];
int ret = [[formatter stringFromDate:thisdate] intValue]; return ret;
} -(int)Weekday
{
NSCalendar* cal = [NSCalendar currentCalendar];
NSDateComponents* weekday = [cal components:NSWeekdayCalendarUnit fromDate:thisdate];
return [weekday weekday];
} -(NSString *)Constellation
{
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"MMdd"];
int intConstellation = [[formatter stringFromDate:thisdate] intValue]; if (intConstellation >= && intConstellation <= )
return @"Aquarius";
else if (intConstellation >= && intConstellation <= )
return @"Pisces";
else if (intConstellation >= && intConstellation <= )
return @"Aries";
else if (intConstellation >= && intConstellation <= )
return @"Taurus";
else if (intConstellation >= && intConstellation <= )
return @"Gemini";
else if (intConstellation >= && intConstellation <= )
return @"Cancer";
else if (intConstellation >= && intConstellation <= )
return @"Leo";
else if (intConstellation >= && intConstellation <= )
return @"Virgo";
else if (intConstellation >= && intConstellation <= )
return @"Libra";
else if (intConstellation >= && intConstellation <= )
return @"Scorpio";
else if (intConstellation >= && intConstellation <= )
return @"Sagittarius";
else
return @"Capricorn";
} @end @implementation NSDate (LunarCalendar) /****************************************************
*@Description:获得NSDate对应的中国日历(农历)的NSDate
*@Params:nil
*@Return:NSDate对应的中国日历(农历)的LunarCalendar
****************************************************/
- (LunarCalendar *)chineseCalendarDate
{
LunarCalendar *lunarCalendar = [[LunarCalendar alloc] init];
[lunarCalendar loadWithDate:self];
[lunarCalendar InitializeValue]; return lunarCalendar;
} @end

然后以我昨天使用的TimesSquare为例.

先找到每个日期按钮生成的地方.TimesSquare日历的就是在TSQCalendarRowCell的createDayButtons方法.

找到后,在里面增加一个label.如红框所示

记得import刚创建的农历文件LunarCalendar.h

然后如红框使用

效果如图:

iOS 给三方日历加上农历的更多相关文章

  1. iOS 常用三方类库整理

    iOS 常用三方类库整理 1:基于响应式编程思想的oc 地址:https://github.com/ReactiveCocoa/ReactiveCocoa 2:hud提示框 地址:https://gi ...

  2. Google日历添加农历、节日和天气插件(步骤)

    Google日历添加农历.节日和天气插件(步骤) Google功能非常多,Google日历只是其中一个,而且支持Exchange账户(iPhone,WP7,诺基亚等)和Google账户登录(andro ...

  3. 设置代码ios 6添加日历事件No calendar has been set.错误

    查了好多资料,发明还是不全,干脆自己整理吧,至少保证在我的做法正确的,以免误导读者,也是给自己做个记录吧! 在iOS 6做日历事件添加时,来来回回报错,No calendar has been set ...

  4. iOS 常用三方(持续更新)

    iOS 常用三方 1.ZWMSegmentController 分页控制器 https://github.com/weiming4219/ZWMSegmentController

  5. WP8日历(含农历)APP

    WP8日历(含农历)APP WP8日历(含农历)APP UI XAML(部分) <phone:PhoneApplicationPage xmlns:CustomControl="clr ...

  6. iOS日历显示农历信息

    第一次接触到日历的开发,表示需要学习的东西还有很多呢! 关于日历的开发,如果不进行相关设置的话,默认是没有农历的,需要我们进行设置. 核心Demo如下: monthArr = [NSArray arr ...

  7. iOS - OC NSCalendar 日历

    前言 @interface NSCalendar : NSObject <NSCopying, NSSecureCoding> NSCalendar 对世界上现存的常用的历法进行了封装,既 ...

  8. iOS - Swift NSCalendar 日历

    前言 public class NSCalendar : NSObject, NSCopying, NSSecureCoding NSCalendar 对世界上现存的常用的历法进行了封装,既提供了不同 ...

  9. iOS中的日历

    iOS自带三种日历,公历.佛教日历和日本日历,要设置日历可以进入"设置-通用-语言与地区-日历"设置,我们中国使用的iPhone默认设置成公历.而泰国人使用的iPhone默认设置的 ...

随机推荐

  1. 【Luogu P2781】 传教

    这题是可以用线段树做的. 虽然$n\leq 10^9$ 可以发现,真正需要用到的节点很少,故动态开点,只有需要用到的时候才新建节点. 这里我在下放标记的时候新建节点,因为每操作/查询一个节点都需要先下 ...

  2. 并发编程——多进程——multiprocessing开启进程的方式及其属性(3)

    开启进程的两种方式——Process 方式一:函数方法 from multiprocessing import Process import time def task(name): print('% ...

  3. Visual C++斗地主游戏网络版源代码

    说明:VC++ 6.0写的网络版斗地主游戏,程序基于directx SDK开发,因此你在编译时需要引入相应文件才可以,本斗地主可以支持双人对战.网络对战,游戏随机产生地主,动画发牌,界面也不错,还有声 ...

  4. 【Part1】用JS写一个Blog(node + vue + mongoDB)

    学习JS也有一段时间了,准备试着写一个博客项目,前后端分离开发,后端用node只提供数据接口,前端用vue-cli脚手架搭建,路由也由前端控制,数据异步交互用vue的一个插件vue-resourse来 ...

  5. Unity --yield return

    1.yield return null; //暂停协同程序,下一帧再继续往下执行 yield new WaitForFixedUpdate (); //暂停协同程序,等到下一次调用FixedUpdat ...

  6. 通过 purge_relay_logs 自动清理relaylog

    使用背景 线上物理备份任务是在从库上进行的,xtrabackup会在备份binlog的时候执行flush logs,relay-log会rotate到新的一个文件号,导致sql thread线程应用完 ...

  7. 【转】Unity 游戏存档 PlayerPrefs类的用法

    http://www.cnblogs.com/qiaogaojian/p/5969855.html unity3d提供了一个用于本地持久化保存与读取的类——PlayerPrefs.工作原理非常简单,以 ...

  8. php获取客户端mac地址

    exec('/sbin/arp -a 2>&1', $array, $return_val);dump($array);$mac = '';foreach($array as $valu ...

  9. 3种jQuery弹出大图效果

    本实例用到了jquery.imgbox.pack.js库.直接看代码: <!DOCTYPE html> <html lang="en"> <head& ...

  10. BZOJ 3437:小P的牧场(DP+斜率优化)

    小P的牧场[题目描述]背景:小P 是个特么喜欢玩MC 的孩纸...小P 在MC 里有n 个牧场,自西向东呈一字形排列(自西向东用1…n 编号),于是他就烦恼了:为了控制这n 个牧场,他需要在某些牧场上 ...