Skip to content

Instantly share code, notes, and snippets.

@phugee
Last active October 19, 2016 21:56
Show Gist options
  • Select an option

  • Save phugee/c85d19fe7cccc54bcda371c6ed0e11a8 to your computer and use it in GitHub Desktop.

Select an option

Save phugee/c85d19fe7cccc54bcda371c6ed0e11a8 to your computer and use it in GitHub Desktop.
private static String convertToEventReminderString(DateTime reminderDateTime, DateTime relativeDateTime) {
Long diffMilliseconds = reminderDateTime.getTime() - relativeDateTime.getTime();
Long minutes = diffMilliseconds/60000;
//case statement for minutes (0, 5, 10, 15, 30),
//if (minutes > 30) {
// //hours (1-11 hour) = {}
// if (minutes <= 660) {
// if (minutes == 60) {
// return '1 hour';
// }
// else
// return (minutes/60) + ' hours';
// }
// else if (minutes == 10080) {
// //weeks (1,2) == {10080, 20160}
// return '1 week';
// }
// else if (minutes == 20160) {
// //weeks (1,2) == {10080, 20160}
// return '2 weeks';
// }
// //days (0.5 days, 1 day, 18 hours, 2 days, 3 days, 4 days) == {720, 1440, 1080, 2880, 4200, 5760}
// else if (Math.mod(minutes, 720) == 0) {
// if (minutes == 1080) {
// return '18 hours';
// }
// else if (minutes == 1440) {
// return '1 day';
// }
// else if (minutes == 720) {
// return '0.5 days';
// }
// else {
// return (minutes/1440) + ' days';
// }
// }
//}
return String.valueOf(minutes);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment