// Path: app/src/main/java/org/andstatus/todoagenda/prefs/SnapshotMode.java
// public enum SnapshotMode {
//     LIVE_DATA("live_data", R.string.snapshot_mode_live_data),
//     SNAPSHOT_TIME("snapshot_time", R.string.snapshot_mode_time),
//     SNAPSHOT_NOW("snapshot_now", R.string.snapshot_mode_now);
// 
//     public final static SnapshotMode defaultValue = LIVE_DATA;
// 
//     public final String value;
//     @StringRes
//     public final int valueResId;
// 
//     SnapshotMode(String value, int valueResId) {
//         this.value = value;
//         this.valueResId = valueResId;
//     }
// 
//     public static SnapshotMode fromValue(String value) {
//         for (SnapshotMode item : SnapshotMode.values()) {
//             if (item.value.equals(value)) {
//                 return item;
//             }
//         }
//         return defaultValue;
//     }
// }


import androidx.annotation.Nullable;
import org.andstatus.todoagenda.prefs.SnapshotMode;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.joda.time.Days;
import org.joda.time.Minutes;
    public SnapshotMode getSnapshotMode() {
        return snapshotMode;
    }

    /**
     * Usually returns real "now", but may be #setNow to some other time for testing purposes
     */
    public DateTime now() {
        return now(zone);
    }

    public DateTime now(DateTimeZone zone) {
        DateTime snapshotDate = this.snapshotDate;
        if (getSnapshotMode() == SnapshotMode.SNAPSHOT_TIME && snapshotDate != null) {
            return PermissionsUtil.isTestMode()
                    ? getTimeMachineDate(zone)
                    : snapshotDate.withZone(zone);
        } else {
            return DateTime.now(zone);
        }
    }

    private DateTime getTimeMachineDate(DateTimeZone zone) {
        DateTime nowSetAt = null;
        DateTime now = null;
        do {
            nowSetAt = snapshotDateSetAt;
            now = snapshotDate;
        } while (nowSetAt != snapshotDateSetAt); // Ensure concurrent consistency

// Path: app/src/main/java/org/andstatus/todoagenda/prefs/SnapshotMode.java
// public enum SnapshotMode {
//     LIVE_DATA("live_data", R.string.snapshot_mode_live_data),
//     SNAPSHOT_TIME("snapshot_time", R.string.snapshot_mode_time),
//     SNAPSHOT_NOW("snapshot_now", R.string.snapshot_mode_now);
// 
//     public final static SnapshotMode defaultValue = LIVE_DATA;
// 
//     public final String value;
//     @StringRes
//     public final int valueResId;
// 
//     SnapshotMode(String value, int valueResId) {
//         this.value = value;
//         this.valueResId = valueResId;
//     }
// 
//     public static SnapshotMode fromValue(String value) {
//         for (SnapshotMode item : SnapshotMode.values()) {
//             if (item.value.equals(value)) {
//                 return item;
//             }
//         }
//         return defaultValue;
//     }
// }


// Path: app/src/main/java/org/andstatus/todoagenda/util/MyClock.java
import androidx.annotation.Nullable;
import org.andstatus.todoagenda.prefs.SnapshotMode;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.joda.time.Days;
import org.joda.time.Minutes;

    public SnapshotMode getSnapshotMode() {
        return snapshotMode;
    }

    /**
     * Usually returns real "now", but may be #setNow to some other time for testing purposes
     */
    public DateTime now() {
        return now(zone);
    }

    public DateTime now(DateTimeZone zone) {
        DateTime snapshotDate = this.snapshotDate;
        if (getSnapshotMode() == SnapshotMode.SNAPSHOT_TIME && snapshotDate != null) {
            return PermissionsUtil.isTestMode()
                    ? getTimeMachineDate(zone)
                    : snapshotDate.withZone(zone);
        } else {
            return DateTime.now(zone);
        }
    }

    private DateTime getTimeMachineDate(DateTimeZone zone) {
        DateTime nowSetAt = null;
        DateTime now = null;
        do {
            nowSetAt = snapshotDateSetAt;
            now = snapshotDate;
        } while (nowSetAt != snapshotDateSetAt); // Ensure concurrent consistency

        if (now == null) {