Commit 72c1cad3 authored by 王品堯's avatar 王品堯

時間格式換成timestamp

parent c85fc759
......@@ -79,8 +79,8 @@
HKQuantity *quantity = sample.quantity;
double value = [quantity doubleValueForUnit:unit];
NSString *startDateString = [RCTAppleHealthKit buildISO8601StringFromDate:sample.startDate];
NSString *endDateString = [RCTAppleHealthKit buildISO8601StringFromDate:sample.endDate];
int startDateTimestamp = [RCTAppleHealthKit buildTimestampFromDate:sample.startDate];
int endDateTimestamp = [RCTAppleHealthKit buildTimestampFromDate:sample.endDate];
NSString *deviceName = sample.device.name ? sample.device.name : @"";
NSString *deviceManufacturer = sample.device.manufacturer ? sample.device.manufacturer : @"";
......@@ -98,8 +98,8 @@
NSDictionary *elem = @{
@"value" : @(value),
@"startDate" : startDateString,
@"endDate" : endDateString,
@"startDate" : @(startDateTimestamp),
@"endDate" : @(endDateTimestamp),
@"deviceName" : deviceName,
@"deviceManufacturer" : deviceManufacturer,
@"deviceHardware" : deviceHardwareVer,
......@@ -166,26 +166,11 @@
// HKCategoryType *catType = sample.categoryType;
NSInteger val = sample.value;
// HKQuantity *quantity = sample.quantity;
// double value = [quantity doubleValueForUnit:unit];
NSString *startDateString = [RCTAppleHealthKit buildISO8601StringFromDate:sample.startDate];
NSString *endDateString = [RCTAppleHealthKit buildISO8601StringFromDate:sample.endDate];
int startDateTimestamp = [RCTAppleHealthKit buildTimestampFromDate:sample.startDate];
int endDateTimestamp = [RCTAppleHealthKit buildTimestampFromDate:sample.endDate];
NSString *valueString = [NSString stringWithFormat:@"%d", val];
// switch (val) {
// case HKCategoryValueSleepAnalysisInBed:
// valueString = @"INBED";
// break;
// case HKCategoryValueSleepAnalysisAsleep:
// valueString = @"ASLEEP";
// break;
// default:
// valueString = @"UNKNOWN";
// break;
// }
NSString *deviceName = sample.device.name ? sample.device.name : @"";
NSString *deviceManufacturer = sample.device.manufacturer ? sample.device.manufacturer : @"";
NSString *deviceHardwareVer = sample.device.hardwareVersion ? sample.device.hardwareVersion : @"";
......@@ -202,8 +187,8 @@
NSDictionary *elem = @{
@"value" : valueString,
@"startDate" : startDateString,
@"endDate" : endDateString,
@"startDate" : @(startDateTimestamp),
@"endDate" : @(endDateTimestamp),
@"deviceName" : deviceName,
@"deviceManufacturer" : deviceManufacturer,
@"deviceHardware" : deviceHardwareVer,
......@@ -222,22 +207,9 @@
}
};
// HKSampleQuery *query = [[HKSampleQuery alloc] initWithSampleType:quantityType
// predicate:predicate
// limit:lim
// sortDescriptors:@[timeSortDescriptor]
// resultsHandler:handlerBlock];
HKCategoryType *categoryType =
[HKObjectType categoryTypeForIdentifier:HKCategoryTypeIdentifierSleepAnalysis];
// HKCategorySample *categorySample =
// [HKCategorySample categorySampleWithType:categoryType
// value:value
// startDate:startDate
// endDate:endDate];
HKSampleQuery *query = [[HKSampleQuery alloc] initWithSampleType:categoryType
predicate:predicate
limit:lim
......@@ -249,17 +221,6 @@
}
- (void)fetchCorrelationSamplesOfType:(HKQuantityType *)quantityType
unit:(HKUnit *)unit
predicate:(NSPredicate *)predicate
......@@ -287,13 +248,13 @@
dispatch_async(dispatch_get_main_queue(), ^{
for (HKCorrelation *sample in results) {
NSString *startDateString = [RCTAppleHealthKit buildISO8601StringFromDate:sample.startDate];
NSString *endDateString = [RCTAppleHealthKit buildISO8601StringFromDate:sample.endDate];
int startDateTimestamp = [RCTAppleHealthKit buildTimestampFromDate:sample.startDate];
int endDateTimestamp = [RCTAppleHealthKit buildTimestampFromDate:sample.endDate];
NSDictionary *elem = @{
@"correlation" : sample,
@"startDate" : startDateString,
@"endDate" : endDateString,
@"startDate" : @(startDateTimestamp),
@"endDate" : @(endDateTimestamp),
};
[data addObject:elem];
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment