WIP DstHelper
This commit is contained in:
parent
0a545dc92b
commit
43a61f312a
11 changed files with 2360 additions and 2150 deletions
|
@ -19,23 +19,22 @@ tempBasalFunctions.setTempBasal = function setTempBasal(rate, duration, profile,
|
||||||
//var maxSafeBasal = Math.min(profile.max_basal, 3 * profile.max_daily_basal, 4 * profile.current_basal);
|
//var maxSafeBasal = Math.min(profile.max_basal, 3 * profile.max_daily_basal, 4 * profile.current_basal);
|
||||||
|
|
||||||
var maxSafeBasal = tempBasalFunctions.getMaxSafeBasal(profile);
|
var maxSafeBasal = tempBasalFunctions.getMaxSafeBasal(profile);
|
||||||
var round_basal = require('./round-basal');
|
var round_basal = require('./round-basal');
|
||||||
|
|
||||||
if (rate < 0) {
|
if (rate < 0) {
|
||||||
rate = 0;
|
rate = 0;
|
||||||
} // if >30m @ 0 required, zero temp will be extended to 30m instead
|
} else if (rate > maxSafeBasal) {
|
||||||
else if (rate > maxSafeBasal) {
|
|
||||||
rate = maxSafeBasal;
|
rate = maxSafeBasal;
|
||||||
}
|
}
|
||||||
|
|
||||||
var suggestedRate = round_basal(rate, profile);
|
var suggestedRate = round_basal(rate, profile);
|
||||||
if (typeof(currenttemp) !== 'undefined' && typeof(currenttemp.duration) !== 'undefined' && typeof(currenttemp.rate) !== 'undefined' && currenttemp.duration > (duration-10) && currenttemp.duration <= 120 && suggestedRate <= currenttemp.rate * 1.2 && suggestedRate >= currenttemp.rate * 0.8) {
|
if (typeof(currenttemp) !== 'undefined' && typeof(currenttemp.duration) !== 'undefined' && typeof(currenttemp.rate) !== 'undefined' && currenttemp.duration > (duration-10) && currenttemp.duration <= 120 && suggestedRate <= currenttemp.rate * 1.2 && suggestedRate >= currenttemp.rate * 0.8 && duration > 0 ) {
|
||||||
rT.reason += " "+currenttemp.duration+"m left and " + currenttemp.rate + " ~ req " + suggestedRate + "U/hr: no temp required";
|
rT.reason += " "+currenttemp.duration+"m left and " + currenttemp.rate + " ~ req " + suggestedRate + "U/hr: no temp required";
|
||||||
return rT;
|
return rT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (suggestedRate === profile.current_basal) {
|
if (suggestedRate === profile.current_basal) {
|
||||||
if (profile.skip_neutral_temps) {
|
if (profile.skip_neutral_temps === true) {
|
||||||
if (typeof(currenttemp) !== 'undefined' && typeof(currenttemp.duration) !== 'undefined' && currenttemp.duration > 0) {
|
if (typeof(currenttemp) !== 'undefined' && typeof(currenttemp.duration) !== 'undefined' && currenttemp.duration > 0) {
|
||||||
reason(rT, 'Suggested rate is same as profile rate, a temp basal is active, canceling current temp');
|
reason(rT, 'Suggested rate is same as profile rate, a temp basal is active, canceling current temp');
|
||||||
rT.duration = 0;
|
rT.duration = 0;
|
||||||
|
|
|
@ -75,6 +75,7 @@ import info.nightscout.androidaps.plugins.Source.SourceXdripPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Wear.WearPlugin;
|
import info.nightscout.androidaps.plugins.Wear.WearPlugin;
|
||||||
import info.nightscout.androidaps.plugins.XDripStatusline.StatuslinePlugin;
|
import info.nightscout.androidaps.plugins.XDripStatusline.StatuslinePlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.DstHelper.DstHelperPlugin;
|
||||||
import info.nightscout.androidaps.receivers.DataReceiver;
|
import info.nightscout.androidaps.receivers.DataReceiver;
|
||||||
import info.nightscout.androidaps.receivers.KeepAliveReceiver;
|
import info.nightscout.androidaps.receivers.KeepAliveReceiver;
|
||||||
import info.nightscout.androidaps.receivers.NSAlarmReceiver;
|
import info.nightscout.androidaps.receivers.NSAlarmReceiver;
|
||||||
|
@ -190,6 +191,8 @@ public class MainApp extends Application {
|
||||||
|
|
||||||
pluginsList.add(ConfigBuilderPlugin.getPlugin());
|
pluginsList.add(ConfigBuilderPlugin.getPlugin());
|
||||||
|
|
||||||
|
pluginsList.add(DstHelperPlugin.getPlugin());
|
||||||
|
|
||||||
ConfigBuilderPlugin.getPlugin().initialize();
|
ConfigBuilderPlugin.getPlugin().initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -156,6 +156,12 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||||
|
log.info("Do nothing for downgrading...");
|
||||||
|
log.debug("oldVersion: {}, newVersion: {}", oldVersion, newVersion);
|
||||||
|
}
|
||||||
|
|
||||||
public int getOldVersion() {
|
public int getOldVersion() {
|
||||||
return oldVersion;
|
return oldVersion;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,129 @@
|
||||||
|
package info.nightscout.androidaps.plugins.DstHelper;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.TimeZone;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.MainApp;
|
||||||
|
import info.nightscout.androidaps.R;
|
||||||
|
import info.nightscout.androidaps.interfaces.Constraint;
|
||||||
|
import info.nightscout.androidaps.interfaces.ConstraintsInterface;
|
||||||
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
|
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||||
|
import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
|
import info.nightscout.androidaps.logging.L;
|
||||||
|
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
||||||
|
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
||||||
|
import info.nightscout.utils.DateUtil;
|
||||||
|
import info.nightscout.utils.T;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Rumen on 31.10.2018.
|
||||||
|
*/
|
||||||
|
public class DstHelperPlugin extends PluginBase implements ConstraintsInterface {
|
||||||
|
private static Logger log = LoggerFactory.getLogger(L.CONSTRAINTS);
|
||||||
|
private int minutesToChange = 0;
|
||||||
|
|
||||||
|
static DstHelperPlugin plugin = null;
|
||||||
|
public static DstHelperPlugin getPlugin() {
|
||||||
|
if (plugin == null)
|
||||||
|
plugin = new DstHelperPlugin();
|
||||||
|
return plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DstHelperPlugin() {
|
||||||
|
super(new PluginDescription()
|
||||||
|
.mainType(PluginType.CONSTRAINTS)
|
||||||
|
.neverVisible(true)
|
||||||
|
.alwaysEnabled(true)
|
||||||
|
.showInList(false)
|
||||||
|
.pluginName(R.string.dst_plugin_name)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int dstTest(Calendar c) throws Exception {
|
||||||
|
// c = Calendar.getInstance(TimeZone.getDefault());
|
||||||
|
// c = Calendar.getInstance(TimeZone.getTimeZone("Australia/Lord_Howe"));
|
||||||
|
// c.setTimeInMillis(DateUtil.fromISODateString("2018-10-07T01:00:00Z").getTime());
|
||||||
|
long zoneOffset = c.get(Calendar.ZONE_OFFSET);
|
||||||
|
long d1 = c.getTimeInMillis()-zoneOffset;
|
||||||
|
c.setTimeInMillis(d1);
|
||||||
|
int offset1 = c.get(Calendar.DST_OFFSET);
|
||||||
|
|
||||||
|
c.add(Calendar.DATE, 1);
|
||||||
|
long d2 = c.getTimeInMillis();
|
||||||
|
|
||||||
|
int diffInHours = (int) ((d1 - d2) / -T.hours(1).msecs());
|
||||||
|
long offsetDetectedTime = 0;
|
||||||
|
// comparing millis because change can be < 1 hour
|
||||||
|
// log.debug("Starting from: "+startTimeString + " to "+endTimeString);
|
||||||
|
// log.debug("start "+offset1+" end "+c.get(Calendar.DST_OFFSET));
|
||||||
|
if (offset1 != c.get(Calendar.DST_OFFSET)) {
|
||||||
|
//we have a time change in next 24 hours, but when exactly
|
||||||
|
// log.debug("Daylight saving time detected between " + startTimeString + " and " + endTimeString);
|
||||||
|
// log.debug("Diff in hours is: "+diffInHours);
|
||||||
|
c.setTimeInMillis(d1-zoneOffset);
|
||||||
|
offset1 = c.get(Calendar.DST_OFFSET);
|
||||||
|
for(int i = 0; i <= diffInHours*4; i++){
|
||||||
|
|
||||||
|
if(offset1 != c.get(Calendar.DST_OFFSET)){
|
||||||
|
log.debug("Detected offset in "+((i/4)-zoneOffset/T.hours(1).msecs())+" hours value is "+(offset1 - c.get(Calendar.DST_OFFSET))/T.mins(1).msecs()+" minutes");
|
||||||
|
offsetDetectedTime = c.getTimeInMillis() - d1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
c.add(Calendar.MINUTE,15);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int minutesLeft = (int) ((offsetDetectedTime/T.mins(1).msecs()));
|
||||||
|
/*log.debug("zoneoffset(minutes):"+zoneOffset/T.mins(1).msecs());
|
||||||
|
log.debug("Start offset: "+offset1/T.mins(1).msecs());
|
||||||
|
log.debug("End offset :" + c.get(Calendar.DST_OFFSET)/T.mins(1).msecs());
|
||||||
|
log.debug("Now is:"+startTimeString);
|
||||||
|
log.debug("Detected in(min): "+(offsetDetectedTime/T.mins(1).msecs()));
|
||||||
|
log.debug("Returning value of: " + minutesLeft); */
|
||||||
|
minutesToChange = minutesLeft;
|
||||||
|
return minutesLeft;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//Return false if time to DST change is less than 91 and positive
|
||||||
|
@Override
|
||||||
|
public Constraint<Boolean> isClosedLoopAllowed(Constraint<Boolean> value){
|
||||||
|
try {
|
||||||
|
this.dstTest(Calendar.getInstance());
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
if ( this.minutesToChange <= 90 && minutesToChange > 0 && value.value()) {
|
||||||
|
try {
|
||||||
|
LoopPlugin loopPlugin = LoopPlugin.getPlugin();
|
||||||
|
if( loopPlugin.suspendedTo() == 0L) {
|
||||||
|
// loopPlugin.suspendTo(System.currentTimeMillis() + minutesToChange * T.mins(1).msecs());
|
||||||
|
warnUser(Notification.DST_LOOP_DISABLED, MainApp.gs(R.string.dst_loop_disabled_warning));
|
||||||
|
} else
|
||||||
|
log.debug("Loop already suspended");
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
value.set(false, "DST in 90 minutes or less", this);
|
||||||
|
} else if (minutesToChange <= 24 * T.hours(1).mins() && minutesToChange > 0) {
|
||||||
|
warnUser(Notification.DST_IN_24H, MainApp.gs(R.string.dst_in_24h_warning));
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
// display warning
|
||||||
|
void warnUser(int id, String warningText){
|
||||||
|
Notification notification = new Notification(id, warningText, Notification.LOW);
|
||||||
|
MainApp.bus().post(new EventNewNotification(notification));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -107,9 +107,9 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
|
running = false;
|
||||||
super.onPause();
|
super.onPause();
|
||||||
MainApp.unsubscribe(this);
|
MainApp.unsubscribe(this);
|
||||||
running = false;
|
|
||||||
if (L.isEnabled(L.UI))
|
if (L.isEnabled(L.UI))
|
||||||
log.debug("onPause");
|
log.debug("onPause");
|
||||||
}
|
}
|
||||||
|
@ -173,10 +173,12 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
|
||||||
Activity activity = getActivity();
|
Activity activity = getActivity();
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
activity.runOnUiThread(() -> {
|
activity.runOnUiThread(() -> {
|
||||||
|
try {
|
||||||
|
if (running) {
|
||||||
if (L.isEnabled(L.UI))
|
if (L.isEnabled(L.UI))
|
||||||
log.debug("executing");
|
log.debug("executing");
|
||||||
try {
|
|
||||||
dismiss();
|
dismiss();
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Unhandled exception", e);
|
log.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1364,7 +1364,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
|
|
||||||
// Sensitivity
|
// Sensitivity
|
||||||
if (sensitivityView != null) {
|
if (sensitivityView != null) {
|
||||||
AutosensData autosensData = IobCobCalculatorPlugin.getPlugin().getLastAutosensDataSynchronized("Overview");
|
AutosensData autosensData = IobCobCalculatorPlugin.getPlugin().getLastAutosensData("Overview");
|
||||||
if (autosensData != null)
|
if (autosensData != null)
|
||||||
sensitivityView.setText(String.format("%.0f%%", autosensData.autosensResult.ratio * 100));
|
sensitivityView.setText(String.format("%.0f%%", autosensData.autosensResult.ratio * 100));
|
||||||
else
|
else
|
||||||
|
|
|
@ -71,6 +71,8 @@ public class Notification {
|
||||||
public static final int DEVICENOTPAIRED = 43;
|
public static final int DEVICENOTPAIRED = 43;
|
||||||
public static final int MEDTRONIC_PUMP_ALARM = 44;
|
public static final int MEDTRONIC_PUMP_ALARM = 44;
|
||||||
public static final int RILEYLINK_CONNECTION = 45;
|
public static final int RILEYLINK_CONNECTION = 45;
|
||||||
|
public static final int DST_LOOP_DISABLED = 46;
|
||||||
|
public static final int DST_IN_24H = 47;
|
||||||
|
|
||||||
|
|
||||||
public int id;
|
public int id;
|
||||||
|
|
|
@ -807,7 +807,7 @@
|
||||||
<string name="hour">hodin</string>
|
<string name="hour">hodin</string>
|
||||||
<string name="day">dní</string>
|
<string name="day">dní</string>
|
||||||
<string name="week">týdnů</string>
|
<string name="week">týdnů</string>
|
||||||
<string name="time_plural"> </string>
|
<string name="time_plural"></string>
|
||||||
<string name="insight_keepalive_format_string">%1$d vyprší %2$s</string>
|
<string name="insight_keepalive_format_string">%1$d vyprší %2$s</string>
|
||||||
<string name="insight_keep_alive_status">Stav keep-alive</string>
|
<string name="insight_keep_alive_status">Stav keep-alive</string>
|
||||||
<string name="statistics">Statistika</string>
|
<string name="statistics">Statistika</string>
|
||||||
|
@ -1052,6 +1052,7 @@
|
||||||
<string name="insulinlimitviolation">Překročen limit inzulínu</string>
|
<string name="insulinlimitviolation">Překročen limit inzulínu</string>
|
||||||
<string name="loop_openmode_min_change">Minimální změna pro výzvu [%]</string>
|
<string name="loop_openmode_min_change">Minimální změna pro výzvu [%]</string>
|
||||||
<string name="loop_openmode_min_change_summary">Smyčka vytvoří novou žádost o změnu pouze v případě, že změna je větší než tato hodnota. Výchozí hodnota je 20 %</string>
|
<string name="loop_openmode_min_change_summary">Smyčka vytvoří novou žádost o změnu pouze v případě, že změna je větší než tato hodnota. Výchozí hodnota je 20 %</string>
|
||||||
|
<string name="pairfirst">Spárujte pumpu s telefonem!</string>
|
||||||
<plurals name="objective_days">
|
<plurals name="objective_days">
|
||||||
<item quantity="one">%1$d den</item>
|
<item quantity="one">%1$d den</item>
|
||||||
<item quantity="few">%1$d dnů</item>
|
<item quantity="few">%1$d dnů</item>
|
||||||
|
|
|
@ -955,7 +955,7 @@ maxIOB = durchschnittlicher Essensbolus + 3 x maximale Basalrate</string>
|
||||||
<string name="virtualpump_pump_def">Bolus: Schritt=%1$s\nVerzögerter Bolus: [Schritt=%2$s, Dauer=%3$smin-%4$sh]\nBasal: Schritt=%5$s\nTBR: %6$s (bei %7$s), Dauer=%8$smin-%9$sh\n%10$s</string>
|
<string name="virtualpump_pump_def">Bolus: Schritt=%1$s\nVerzögerter Bolus: [Schritt=%2$s, Dauer=%3$smin-%4$sh]\nBasal: Schritt=%5$s\nTBR: %6$s (bei %7$s), Dauer=%8$smin-%9$sh\n%10$s</string>
|
||||||
<string name="virtualpump_pump_def_extended_note">* Bei der virtuellen Pumpe können nur einzelne Werte und keine Bereiche zur Festlegung der Basal/Bolus-Granularität gewählt werden.</string>
|
<string name="virtualpump_pump_def_extended_note">* Bei der virtuellen Pumpe können nur einzelne Werte und keine Bereiche zur Festlegung der Basal/Bolus-Granularität gewählt werden.</string>
|
||||||
<string name="ns_autobackfill_title">BZ automatisch auffüllen</string>
|
<string name="ns_autobackfill_title">BZ automatisch auffüllen</string>
|
||||||
<string name="wear_wizard_settings">Einrichtungsassistent</string>
|
<string name="wear_wizard_settings">Wizard-Einstellungen</string>
|
||||||
<string name="wear_wizard_settings_summary">Berechnungen, die im Assistenten berücksichtigt werden:</string>
|
<string name="wear_wizard_settings_summary">Berechnungen, die im Assistenten berücksichtigt werden:</string>
|
||||||
<string name="wear_display_settings">Anzeigeeinstellungen</string>
|
<string name="wear_display_settings">Anzeigeeinstellungen</string>
|
||||||
<string name="wear_general_settings">Allgemeine Einstellungen</string>
|
<string name="wear_general_settings">Allgemeine Einstellungen</string>
|
||||||
|
|
|
@ -1210,6 +1210,9 @@
|
||||||
<string name="loop_openmode_min_change_summary">Loop will popup new change request only if change is bigger than this value. Default value is 20%</string>
|
<string name="loop_openmode_min_change_summary">Loop will popup new change request only if change is bigger than this value. Default value is 20%</string>
|
||||||
<string name="key_short_tabtitles" translatable="false">short_tabtitles</string>
|
<string name="key_short_tabtitles" translatable="false">short_tabtitles</string>
|
||||||
<string name="pairfirst">Please pair your pump with your phone!</string>
|
<string name="pairfirst">Please pair your pump with your phone!</string>
|
||||||
|
<string name="dst_plugin_name" translatable="false">Dayligh Saving time</string>
|
||||||
|
<string name="dst_in_24h_warning">Dayligh Saving time change in 24h or less</string>
|
||||||
|
<string name="dst_loop_disabled_warning">Dayligh Saving time change in less than 3 hours - Closed loop diabled</string>
|
||||||
|
|
||||||
<plurals name="objective_days">
|
<plurals name="objective_days">
|
||||||
<item quantity="one">%1$d day</item>
|
<item quantity="one">%1$d day</item>
|
||||||
|
|
|
@ -0,0 +1,65 @@
|
||||||
|
package info.nightscout.androidaps.plugins.DstHelper;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||||
|
import org.powermock.modules.junit4.PowerMockRunner;
|
||||||
|
import junit.framework.Assert;
|
||||||
|
|
||||||
|
import info.AAPSMocker;
|
||||||
|
import info.nightscout.androidaps.MainApp;
|
||||||
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
|
import info.nightscout.utils.DateUtil;
|
||||||
|
import info.nightscout.utils.SP;
|
||||||
|
import info.nightscout.utils.T;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.TimeZone;
|
||||||
|
|
||||||
|
@RunWith(PowerMockRunner.class)
|
||||||
|
@PrepareForTest({MainApp.class, ConfigBuilderPlugin.class, SP.class, Context.class})
|
||||||
|
public class DstHelperPluginTest {
|
||||||
|
DstHelperPlugin plugin = new DstHelperPlugin();
|
||||||
|
@Test
|
||||||
|
public void runTest() throws Exception {
|
||||||
|
AAPSMocker.mockMainApp();
|
||||||
|
AAPSMocker.mockApplicationContext();
|
||||||
|
// test different time zones
|
||||||
|
//Starting with Europe/Sofia
|
||||||
|
Calendar c = Calendar.getInstance(TimeZone.getTimeZone("Europe/Sofia"));
|
||||||
|
c.setTimeInMillis(DateUtil.fromISODateString("2018-10-28T02:00:00Z").getTime());
|
||||||
|
int minutesLeftToChange = plugin.dstTest(c);
|
||||||
|
Assert.assertEquals(60, minutesLeftToChange);
|
||||||
|
c.setTimeInMillis(DateUtil.fromISODateString("2018-03-25T02:00:00Z").getTime());
|
||||||
|
minutesLeftToChange = plugin.dstTest(c);
|
||||||
|
Assert.assertEquals(60, minutesLeftToChange);
|
||||||
|
// try something with half hour somewhere in Australia
|
||||||
|
c = Calendar.getInstance(TimeZone.getTimeZone("Australia/Lord_Howe"));
|
||||||
|
c.setTimeInMillis(DateUtil.fromISODateString("2018-04-01T00:00:00Z").getTime());
|
||||||
|
minutesLeftToChange = plugin.dstTest(c);
|
||||||
|
// try something with half hour somewhere in Australia
|
||||||
|
c = Calendar.getInstance(TimeZone.getTimeZone("Australia/Lord_Howe"));
|
||||||
|
c.setTimeInMillis(DateUtil.fromISODateString("2018-04-01T00:00:00Z").getTime());
|
||||||
|
minutesLeftToChange = plugin.dstTest(c);
|
||||||
|
Assert.assertEquals(90, minutesLeftToChange);
|
||||||
|
c = Calendar.getInstance(TimeZone.getTimeZone("Australia/Lord_Howe"));
|
||||||
|
// and back
|
||||||
|
c.setTimeInMillis(DateUtil.fromISODateString("2018-10-07T00:00:00Z").getTime());
|
||||||
|
minutesLeftToChange = plugin.dstTest(c);
|
||||||
|
Assert.assertEquals(120, minutesLeftToChange);
|
||||||
|
|
||||||
|
c.setTimeInMillis(DateUtil.fromISODateString("2018-10-08T00:00:00Z").getTime());
|
||||||
|
minutesLeftToChange = plugin.dstTest(c);
|
||||||
|
Assert.assertEquals(0, minutesLeftToChange);
|
||||||
|
|
||||||
|
// DST event was 30 mins
|
||||||
|
c.setTimeInMillis(DateUtil.fromISODateString("2018-04-01T02:00:00Z").getTime());
|
||||||
|
minutesLeftToChange = plugin.dstTest(c);
|
||||||
|
// Assert.assertEquals(630, plugin.zoneOffsetInMinutes(c));
|
||||||
|
Assert.assertEquals(0, minutesLeftToChange);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue