datetime

guidoarfini

Member
Licensed User
Longtime User
i have create litte app for datetime, but don't work in correct modo becose when change the day.... :BangHead:

this app using database ( in this example editext) for day and time start and finsh stored...

can you help me?
 

Attachments

  • datetime.zip
    8.3 KB · Views: 226

guidoarfini

Member
Licensed User
Longtime User
quando faccio partire un tempo a coundown e questo finisce il giorno dopo, il conteggio del tempo rimanente risulta essere sbagliato di 12 ore;



a time when I start to coundown and this ends the next day, the count of the remaining time turns out to be wrong in 12 hours;
 
Upvote 0

Ricky D

Well-Known Member
Licensed User
Longtime User
I'm a novice on android but let's say you have this

B4X:
Dim start, theend, diff As Long
    start = Datetime. Now
'do some code
    thend = Datetime.Now

  diff = thend - start
'now calculate the hours, minutes & seconds
'diff/1000 gets rid of the milliseconds

to take care of different days get the day count * 24 to get the extra hours to add to the hours of the time portion

I'll try it when I get up after ending work

regards Ricky
 
Upvote 0

guidoarfini

Member
Licensed User
Longtime User
this a problem

now i have update my app, but these are the problems;

example:
time to insert de service are 20:00 of day1
i can insert work countdown 00:20:00 or insert countdown of 02:00:00;
app calcolate in correct mode the day and hours correct finsh:sign0098:

but

time to insert the servis are 00:01:00 of day2
don't work, the app don't calculate the time of finish work:BangHead:

sorry for my english
 

Attachments

  • dataora.zip
    8.7 KB · Views: 170
Upvote 0

guidoarfini

Member
Licensed User
Longtime User
help me

if it's 23:50 when I start the service calculates the hours and the correct date the service ends, while if it's 00:01, do not calculate correctly the day of service ends.

for example: the value of comDurataServizio.text = "00:20:00"

Adesso = DateTime.now :
GiornoAttuale = DateTime.Date(Adesso)
OraAttuale = DateTime.Time(Adesso)

DurataSER = ComDurataServizio.Text
PrimoDuePunti = DurataSER.IndexOf(":")
OreDaAgg = DurataSER.SubString2(0, PrimoDuePunti)
SecondoDuePunti = DurataSER.LastIndexOf(":")
MinDaAgg = DurataSER.SubString2(PrimoDuePunti + 1, SecondoDuePunti)
SecDaAgg = DurataSER.SubString2(SecondoDuePunti + 1, DurataSER.Length)
MillisecondiDaAgg = DateTime.TicksPerHour * OreDaAgg + DateTime.TicksPerMinute * MinDaAgg + DateTime.TicksPerSecond * SecDaAgg
TempoScadenza = DateTime.TimeParse(OraAttuale) + MillisecondiDaAgg
GiornoScadenza = DateTime.Date(TempoScadenza)
OraScadenza = DateTime.Time(TempoScadenza)
ComIniConsumazione.Text=OraAttuale
comFineConsumazione.Text=OraScadenza
FinServGiorno=GiornoScadenza
 
Upvote 0
Top