Profile now defaults to local time zone. Works in the client but will break on the server. Time zone and units field added to documentation.

This commit is contained in:
Sulka Haro
2015-07-13 09:54:24 +03:00
parent 34daa67a7a
commit 78328dc841
2 changed files with 8 additions and 8 deletions
+2
View File
@@ -312,6 +312,8 @@ Use the [autoconfigure tool][autoconfigure] to sync an uploader to your config.
Treatment Profile Fields:
* `timezone` (Time Zone) - time zone local to the patient. *Should be set.*
* `units` (Profile Units) - blood glucose units used in the profile, either "mgdl" or "mmol"
* `dia` (Insulin duration) - value should be the duration of insulin action to use in calculating how much insulin is left active. Defaults to 3 hours.
* `carbs_hr` (Carbs per Hour) - The number of carbs that are processed per hour, for more information see [#DIYPS](http://diyps.org/2014/05/29/determining-your-carbohydrate-absorption-rate-diyps-lessons-learned/).
* `carbratio` (Carb Ratio) - grams per unit of insulin.
+6 -8
View File
@@ -39,15 +39,13 @@ function init(profileData) {
profile.getValueByTime = function getValueByTime (time, valueContainer) {
if (!time) { time = Date.now(); }
var tz = 'UTC';
if (profile.getTimezone()) {
tz = profile.getTimezone();
}
// Assumes the timestamps are in UTC
// Use local time zone if profile doesn't contain a time zone
// This WILL break on the server; added warnings elsewhere that this is missing
// TODO: Better warnings to user for missing configuration
// correctly converts both Dates and timestamps
// assume all timestamps are UTC, convert to local time
// Dates convert correctly every time, assuming correct time zone
var t = moment(time).tz(tz);
var t = profile.getTimezone() ? moment(time).tz(profile.getTimezone()) : moment(time);
// Convert to seconds from midnight
var mmtMidnight = t.clone().startOf('day');