Change time format
Posted: 06 Dec 2019 16:31
Can i convert standard time output, example "08:30" to milliseconds so i can use getduration with real time and next alarm?
Code: Select all
tz = -getDate("{0,dateformat,z}", "z");
Code: Select all
tz = -getDate(0, "s");
Code: Select all
today = getDate(getDate(), 0, 0, 0);
Code: Select all
mili = getDate("08:30", "hh:mm");
Code: Select all
mili = getDate("08:30", "hh:mm");
tz = -getDate(0, "s");
cmili = mili + tz;
Code: Select all
global_alarm = next_alarm
// this is a glovar i already have, just showing you what global_alarn is.
true_time = "{getDate(),dateformat,HH:mm}";
// grab now time in same format as alarm minus the day that i donot want.
tempalarm = global_alarm;
//give my glovar a temporary home.
Strippedalarm = right(tempalarm, length(tempalarm) - 4);
//strip the day "sat" from the alarm time.
//this is where i would apply your code to reformat.
global_time_runtime =
(Strippedalarm - true_time);
// this should give duration between times in milliseconds.
global_time_runtime_formated =
getDurationString(global_time_runtime);
// convert the milliseconds format to string to give me a readout of "2d 3h 22m" (as example).!
Code: Select all
global_alarm = next_alarm; //example "Mon 09:55"
talarm = getDate(global_alarm, "EEE HH:mm"); //get alarm time using the pattern
toweek = getDate() / (7*86400000) * (7*86400000); //this find current week
nexta = toweek + talarm; //plus the alarm and current week
if(nexta < getDate())
nexta = addDays(nexta, 7); //if next alarm is in the past, add it with 7 days
global_time_runtime = nexta - getDate(); //find the duration in milliseconds
global_time_runtime_formated = getDurationString(global_time_runtime); //Format the duration