CFAbsoluteTimeAddGregorianUnits
日付を増減して返します
CFAbsoluteTime CFAbsoluteTimeAddGregorianUnits ( CFAbsoluteTime at , CFTimeZoneRef tz , CFGregorianUnits units );
解説
日付を増減して返します。
返り値
引数
( CFAbsoluteTime )at
( CFTimeZoneRef )tz
( CFGregorianUnits )units
クラス
CFDate
Function
使用可能
10.0
参照
例文
#include <CoreFoundation/CoreFoundation.h> static const CFGregorianUnits kGregorianUnits_Plus24Hours = {0, 0, 0, 24, 0, 0.0}; static const CFGregorianUnits kGregorianUnits_Minus24Hours = {0, 0, 0, -24, 0, 0.0}; int main (int argc, const char * argv[]) { CFTimeZoneRef zone = CFTimeZoneCreateWithTimeIntervalFromGMT(NULL, 0.0); CFAbsoluteTime timeNow = CFAbsoluteTimeGetCurrent(); CFAbsoluteTime timeNow2 =CFAbsoluteTimeAddGregorianUnits(timeNow,zone,kGregorianUnits_Plus24Hours); CFGregorianDate current = CFAbsoluteTimeGetGregorianDate( timeNow2, NULL ); double dsecs = floor(current.second); unsigned int second = (unsigned int)dsecs; double milliseconds = (current.second - dsecs) * 1000.0; CFStringRef theString = CFStringCreateWithFormat (kCFAllocatorDefault,NULL,CFSTR("%@ %d.%d.%d %d:%d:%d.%u\n"), CFSTR("It's"),current.year, current.month, current.day, current.hour, current.minute, second, (unsigned int)milliseconds); CFShow(theString); return 0; }