Italian [risolto] B4J incremento data di 7 giorni

ivanomonti

Expert
Licensed User
Longtime User
ciao ragazzi oggi son fuso, mi date un suggerimento che mi sono perso su youporn :)
 

LucaMs

Expert
Licensed User
Longtime User
ciao ragazzi oggi son fuso, mi date un suggerimento che mi sono perso su youporn :)
Gira la 2a a sinistra, poi sempre dritto (su quel sito, eh 😄)

B4X:
DateTime.DateFormat = "dd/mm/yyyy"

Dim data1 As Long = DateTime.DateParse("29/04/2020")
   Log(DateTime.Date(data1))
Dim data2 As Long
data2 = data1 + DateTime.TicksPerDay * 7
   Log(DateTime.Date(data2))
 

ivanomonti

Expert
Licensed User
Longtime User
mi sa che anche il pc deve andare a farsi fottere hahahah

Waiting for debugger to connect...
Program started.
2020-04-29
2020-09-02
1970-01-08

B4X:
DateTime.DateFormat="YYYY-MM-dd"
    
    Dim s,e As String
    Dim ts, te, ta As Long
    Dim tot As Int
    
    s = DateTime.Date(startday.DateTicks)
    e = DateTime.Date(endday.DateTicks)

    Log(s)
    Log(e)
    
    ts = DateTime.GetDayOfYear(startday.DateTicks) '------------------------ data start [B]2020-04-29[/B]
    ta = ts+(DateTime.TicksPerDay * 7) ' ------------------- data incrementata [B]1970-01-08[/B]
    Log(DateTime.Date(ta))
    
    te = DateTime.GetDayOfYear(endday.DateTickS) ' ---------------------- mi serve per capire quanti giorni devo replicare con date diverse (ok perfetto)
 

udg

Expert
Licensed User
Longtime User
Cerca AddPeriod
 

ivanomonti

Expert
Licensed User
Longtime User
@udg ma non capisco, cazzarola un incremento nnon ha bisogno di libreria aggiuntiva... e poi quella e per android
 

ivanomonti

Expert
Licensed User
Longtime User
RAGAZZI TROPPO PORNO NEL CERVELLO,,, CHE NON VEDO CIO' CHE SCRIVO ... PERDONATEMI
 

LucaMs

Expert
Licensed User
Longtime User
Il codice che avevo pubblicato funziona.
Il tuo... non lo capisco, perché non so dove tu prenda quei startday.DateTicks e endday.DateTicks

Comunque, se da qualche parte hai le date memorizzate con quel formato:
B4X:
    DateTime.DateFormat = "yyyy/mm/dd"

    Dim data1 As Long = DateTime.DateParse("2020/04/29")
       Log(DateTime.Date(data1))
    Dim data2 As Long
    data2 = data1 + DateTime.TicksPerDay * 7
       Log(DateTime.Date(data2)) ' log: 2020/04/05

Questo è praticamente uguale, con formato data diverso (e funziona altrettanto, ovviamente).
 

ivanomonti

Expert
Licensed User
Longtime User
@LucaMs tutto a posto ero io che non vedevo l'errore (il mio), in verità le date sono prese da un datapicker ora in queste foto non guardare i formati che sono diversi yyyy-MM-dd con altro che è dd-MM-yyyy.

In sintesi ho aggiunto la possibilità di replicare un appuntamento fisso ogni mercoledì (esempio) fino alla data desiderata, il più grosso lavoro e fare beta test e andare a cercare librerie ed esempi,,, poi non vedo ciò che scrivo. mea colpa e GRAZIE di nuovo

2020-04-29_171521.jpg
 
Top