hi mates,
so i did a function which calculate in days/hours/minutes the time between now and since/until an event.
So far, no issue, but i've just had a complain about time offset.
we are ok that the date picker in settings is in UTC time?
and time.now.value also?
here is my code:
function DayCount(){ if (CheckHours()==2400){return "INVALID TIME";} else { var NOW = Time.now().value(); //var TZO = Sys.getClockTime().timeZoneOffset; var PastFutur = App.getApp().getProperty("ED")+CheckHours();//-TZO; var T =0; var PF=""; if (PastFutur<NOW){ T = NOW.toNumber()-PastFutur.toNumber(); PF = "+"; } else { T = PastFutur.toNumber()-NOW.toNumber(); PF = "-"; } var D = Math.floor(T/86400); var H = Math.floor((T - D*86400)/3600); var M = (T -D*86400 - H*3600)/60; return PF+D.format("%02d")+" D -"+H.format("%02d")+":"+M.format("%02d"); } }
function CheckHours(){ var HM = App.getApp().getProperty("ET").toString(); if (HM.toString().length()!=5){return 2400;} else if( HM.substring(0, 2).toNumber()>23){ return 2400;} else if( HM.substring(3, 5).toNumber()>59){ return 2400;} else { return (HM.substring(0, 2).toNumber()*3600) + (HM.substring(3, 5).toNumber()*60);} }
so when i test on mine (i'm utc+1), no problem at all.
but few users reported time offfset and everytime it is the utc offset,
i did again a test on simulator and i do have offset too (+1h for me) but not on my device.
do you see something wrong in my code?
have a great day