Hopefully fixed gtasks date rounding

pull/14/head
Sam Bosley 13 years ago
parent 3c760480da
commit 8236144d81

@ -46,6 +46,17 @@ public class GtasksApiUtilities {
}
}
public static String unixTimeToGtasksDate(long time) {
if (time == 0) return null;
synchronized(timeWriter) {
Date date = new Date(time);
date.setHours(0);
date.setMinutes(0);
date.setSeconds(0);
return new DateTime(date, TimeZone.getDefault()).toStringRfc3339();
}
}
/*
* The two methods below are useful for testing
*/

@ -208,11 +208,11 @@ public final class GtasksSyncOnSaveService {
remoteModel.notes = task.getValue(Task.NOTES);
}
if (values.containsKey(Task.DUE_DATE.name)) {
remoteModel.due = GtasksApiUtilities.unixTimeToGtasksTime(task.getValue(Task.DUE_DATE));
remoteModel.due = GtasksApiUtilities.unixTimeToGtasksDate(task.getValue(Task.DUE_DATE));
}
if (values.containsKey(Task.COMPLETION_DATE.name)) {
if (task.isCompleted()) {
remoteModel.completed = GtasksApiUtilities.unixTimeToGtasksTime(task.getValue(Task.COMPLETION_DATE));
remoteModel.completed = GtasksApiUtilities.unixTimeToGtasksDate(task.getValue(Task.COMPLETION_DATE));
remoteModel.status = "completed"; //$NON-NLS-1$
} else {
remoteModel.completed = null;

@ -436,10 +436,12 @@ public class GtasksSyncProvider extends SyncProvider<GtasksTaskContainer> {
com.google.api.services.tasks.v1.model.Task model) {
if(shouldTransmit(local, Task.TITLE, remote))
model.title = local.task.getValue(Task.TITLE);
if(shouldTransmit(local, Task.DUE_DATE, remote))
model.due = GtasksApiUtilities.unixTimeToGtasksTime(local.task.getValue(Task.DUE_DATE));
if(shouldTransmit(local, Task.DUE_DATE, remote)) {
model.due = GtasksApiUtilities.unixTimeToGtasksDate(local.task.getValue(Task.DUE_DATE));
System.err.println("Setting model due time to: " + model.due);
}
if(shouldTransmit(local, Task.COMPLETION_DATE, remote)) {
model.completed = GtasksApiUtilities.unixTimeToGtasksTime(local.task.getValue(Task.COMPLETION_DATE));
model.completed = GtasksApiUtilities.unixTimeToGtasksDate(local.task.getValue(Task.COMPLETION_DATE));
model.status = (local.task.isCompleted() ? "completed" : "needsAction");
}
if(shouldTransmit(local, Task.DELETION_DATE, remote))

Loading…
Cancel
Save