Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
rn-apple-healthkit
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Jira
Jira
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ym
rn-apple-healthkit
Commits
fefbb199
Commit
fefbb199
authored
Jun 28, 2016
by
Greg Wilson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changed dateFormat in time methods and added methods to get values from the input options
parent
2f4394ba
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
79 additions
and
2 deletions
+79
-2
RCTAppleHealthKit/RCTAppleHealthKit+Utils.h
RCTAppleHealthKit/RCTAppleHealthKit+Utils.h
+4
-0
RCTAppleHealthKit/RCTAppleHealthKit+Utils.m
RCTAppleHealthKit/RCTAppleHealthKit+Utils.m
+75
-2
No files found.
RCTAppleHealthKit/RCTAppleHealthKit+Utils.h
View file @
fefbb199
...
@@ -15,4 +15,8 @@
...
@@ -15,4 +15,8 @@
+
(
NSPredicate
*
)
predicateForSamplesToday
;
+
(
NSPredicate
*
)
predicateForSamplesToday
;
+
(
NSPredicate
*
)
predicateForSamplesOnDay
:(
NSDate
*
)
date
;
+
(
NSPredicate
*
)
predicateForSamplesOnDay
:(
NSDate
*
)
date
;
+
(
NSPredicate
*
)
predicateForSamplesOnDayFromTimestamp
:(
NSString
*
)
timestamp
;
+
(
NSPredicate
*
)
predicateForSamplesOnDayFromTimestamp
:(
NSString
*
)
timestamp
;
+
(
double
)
doubleValueFromOptions
:(
NSDictionary
*
)
options
;
+
(
NSDate
*
)
dateFromOptionsDefaultNow
:(
NSDictionary
*
)
options
;
+
(
HKUnit
*
)
hkUnitFromOptions
:(
NSDictionary
*
)
options
;
@end
@end
RCTAppleHealthKit/RCTAppleHealthKit+Utils.m
View file @
fefbb199
...
@@ -17,7 +17,8 @@
...
@@ -17,7 +17,8 @@
NSDateFormatter
*
dateFormatter
=
[
NSDateFormatter
new
];
NSDateFormatter
*
dateFormatter
=
[
NSDateFormatter
new
];
NSLocale
*
posix
=
[
NSLocale
localeWithLocaleIdentifier
:
@"en_US_POSIX"
];
NSLocale
*
posix
=
[
NSLocale
localeWithLocaleIdentifier
:
@"en_US_POSIX"
];
dateFormatter
.
locale
=
posix
;
dateFormatter
.
locale
=
posix
;
dateFormatter
.
dateFormat
=
@"yyyy-MM-dd'T'HH:mm:ssZZZZZ"
;
// dateFormatter.dateFormat = @"yyyy-MM-dd'T'HH:mm:ssZZZZZ";
dateFormatter
.
dateFormat
=
@"yyyy'-'MM'-'dd'T'HH':'mm':'ss.SSSZ"
;
return
[
dateFormatter
dateFromString
:
date
];
return
[
dateFormatter
dateFromString
:
date
];
}
}
...
@@ -26,7 +27,8 @@
...
@@ -26,7 +27,8 @@
NSDateFormatter
*
dateFormatter
=
[
NSDateFormatter
new
];
NSDateFormatter
*
dateFormatter
=
[
NSDateFormatter
new
];
NSLocale
*
posix
=
[
NSLocale
localeWithLocaleIdentifier
:
@"en_US_POSIX"
];
NSLocale
*
posix
=
[
NSLocale
localeWithLocaleIdentifier
:
@"en_US_POSIX"
];
dateFormatter
.
locale
=
posix
;
dateFormatter
.
locale
=
posix
;
dateFormatter
.
dateFormat
=
@"yyyy-MM-dd'T'HH:mm:ssZZZZZ"
;
// dateFormatter.dateFormat = @"yyyy-MM-dd'T'HH:mm:ssZZZZZ";
dateFormatter
.
dateFormat
=
@"yyyy'-'MM'-'dd'T'HH':'mm':'ss.SSSZ"
;
return
[
dateFormatter
stringFromDate
:
date
];
return
[
dateFormatter
stringFromDate
:
date
];
}
}
...
@@ -47,4 +49,75 @@
...
@@ -47,4 +49,75 @@
return
[
HKQuery
predicateForSamplesWithStartDate
:
startDate
endDate
:
endDate
options
:
HKQueryOptionStrictStartDate
];
return
[
HKQuery
predicateForSamplesWithStartDate
:
startDate
endDate
:
endDate
options
:
HKQueryOptionStrictStartDate
];
}
}
+
(
double
)
doubleValueFromOptions
:(
NSDictionary
*
)
options
{
double
value
=
[[
options
objectForKey
:
@"value"
]
doubleValue
];
return
value
;
}
+
(
NSDate
*
)
dateFromOptionsDefaultNow
:(
NSDictionary
*
)
options
{
NSString
*
dateString
=
[
options
objectForKey
:
@"date"
];
if
(
dateString
!=
nil
){
NSDate
*
date
=
[
RCTAppleHealthKit
parseISO8601DateFromString
:
dateString
];
if
(
date
==
nil
){
// probably not a good idea... should return an error or just the null pointer
date
=
[
NSDate
date
];
}
return
date
;
}
NSDate
*
now
=
[
NSDate
date
];
return
now
;
}
+
(
HKUnit
*
)
hkUnitFromOptions
:(
NSDictionary
*
)
options
{
NSString
*
unitString
=
[
options
objectForKey
:
@"unit"
];
HKUnit
*
theUnit
;
if
([
unitString
isEqualToString
:
@"gram"
]){
theUnit
=
[
HKUnit
gramUnit
];
}
if
([
unitString
isEqualToString
:
@"pound"
]){
theUnit
=
[
HKUnit
poundUnit
];
}
if
([
unitString
isEqualToString
:
@"meter"
]){
theUnit
=
[
HKUnit
meterUnit
];
}
if
([
unitString
isEqualToString
:
@"inch"
]){
theUnit
=
[
HKUnit
inchUnit
];
}
if
([
unitString
isEqualToString
:
@"foot"
]){
theUnit
=
[
HKUnit
footUnit
];
}
if
([
unitString
isEqualToString
:
@"second"
]){
theUnit
=
[
HKUnit
secondUnit
];
}
if
([
unitString
isEqualToString
:
@"minute"
]){
theUnit
=
[
HKUnit
minuteUnit
];
}
if
([
unitString
isEqualToString
:
@"hour"
]){
theUnit
=
[
HKUnit
hourUnit
];
}
if
([
unitString
isEqualToString
:
@"day"
]){
theUnit
=
[
HKUnit
dayUnit
];
}
if
([
unitString
isEqualToString
:
@"joule"
]){
theUnit
=
[
HKUnit
jouleUnit
];
}
if
([
unitString
isEqualToString
:
@"calorie"
]){
theUnit
=
[
HKUnit
calorieUnit
];
}
if
([
unitString
isEqualToString
:
@"count"
]){
theUnit
=
[
HKUnit
countUnit
];
}
if
([
unitString
isEqualToString
:
@"percent"
]){
theUnit
=
[
HKUnit
percentUnit
];
}
return
theUnit
;
}
@end
@end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment