Connaitre date + 1 avec os.date
Publié : 05 févr. 2022, 22:50
par pierrotori
Est ce que avec un os.date on peut avoir la date +1 comme avec le date Linux et tomorrow ?
Re: [LUA] Horaires de marées
Publié : 05 févr. 2022, 23:07
par Alain78
Bonjour,
Moi j'utilise ça:
local DateJour = os.date('%Y-%m-%d %H:%M:%S')
local DateJourPlus1 = os.date('%Y-%m-%d %H:%M:%S', (os.time()+ 60*60*24))
local DateJourPlus2 = os.date('%Y-%m-%d %H:%M:%S', (os.time()+ 60*60*48))
Récupérer les valeurs nécessaires:
Par contre c'est du Dzvents, a voir si idem en LUA
Alain
Modération
Publié : 06 févr. 2022, 07:37
par Keros
Messages déplacés dans un nouveau sujet.
Re: Connaitre date + 1 avec os.date
Publié : 06 févr. 2022, 14:42
par pierrotori
merci en effet après quelques tests sur les fonction dates
os.date('%d-%m-%Y', (os.time()+ 60*60*24)
est équivalent en dzvents
dz.time.dateToDate(dz.time.addDays(1).rawDateTime,'yyyy-mm-dd hh:MM:ss','dd-mm-yyyy')
dz.time.dateToDate(dz.time.addDays(1).rawDate,'yyyy-mm-dd','dd-mm-yyyy')
ce qui n'est pas si évident au niveau du addDays qui ramène quand même
{["isUTC"]=false, ["localeMonths"]=function, ["matchesRule"]=function, ["monthName"]="February", ["ruleMatchesBetweenRange"]=function, ["containsWholeWord"]=function, ["ruleMatchesTimeRange"]=function, ["isdst"]=false, ["seconds"]=0, ["ruleMatchesTime"]=function, ["current"]={["day"]=6, ["hour"]=14, ["year"]=2022, ["min"]=30, ["isdst"]=false, ["month"]=2, ["yday"]=37, ["sec"]=2, ["wday"]=1}, ["ruleMatchesHourSpecification"]=function, ["getISO"]=function, ["ruleMatchesMinuteSpecification"]=function, ["week"]=6, ["minutesnow"]=870, ["ruleIsAtAstronomicalRange"]=function, ["rawTime"]="14:30:00", ["ruleIsAfterAstrologicalMoment"]=function, ["addMinutes"]=function, ["raw"]="2022-02-07 14:30:00", ["secondsSinceMidnight"]=52200, ["addDays"]=function, ["ruleIsOnDate"]=function, ["ruleIsInWeek"]=function, ["makeTime"]=function, ["toUTC"]=function, ["ruleIsOnDay"]=function, ["msAgo"]=-86397478, ["sec"]=0, ["dateToTimestamp"]=function, ["addSeconds"]=function, ["isToday"]=false, ["dateToDate"]=function, ["hour"]=14, ["timestampToDate"]=function, ["year"]=2022, ["addHours"]=function, ["compare"]=function, ["min"]=30, ["dayName"]="Monday", ["dayAbbrOfWeek"]="mon", ["hoursAgo"]=-23, ["dDate"]=1644240600, ["monthAbbrName"]="feb", ["millisecondsAgo"]=-86397478, ["daysAgo"]=0, ["ruleIsAtAstronomicalMoment"]=function, ["rawDate"]="2022-02-07", ["day"]=7, ["minutesSinceMidnight"]=870, ["secondsAgo"]=-86398, ["minutesAgo"]=-1439, ["rawDateTime"]="2022-02-07 14:30:00", ["milliSeconds"]=0, ["month"]=2, ["ruleIsBeforeAstrologicalMoment"]=function, ["utils"]={["DZVERSION"]="3.1.8", ["dumpSelection"]=function, ["inTable"]=function, ["fromJSON"]=function, ["round"]=function, ["leadingZeros"]=function, ["stringToSeconds"]=function, ["osExecute"]=function, ["osCommand"]=function, ["rightPad"]=function, ["containsWord"]=function, ["humidityStatus"]=function, ["isXML"]=function, ["LOG_ERROR"]=1, ["cloneTable"]=function, ["splitLine"]=function, ["fromBase64"]=function, ["toBase64"]=function, ["LOG_DEBUG"]=4, ["LOG_WARNING"]=3, ["LOG_FORCE"]=0.5, ["hsbToRGB"]=function, ["cameraExists"]=function, ["groupExists"]=function, ["variableExists"]=function, ["LOG_MODULE_EXEC_INFO"]=2, ["fuzzyLookup"]=function, ["urlDecode"]=function, ["hardwareExists"]=function, ["numDecimals"]=function, ["leftPad"]=function, ["dumpTable"]=function, ["stringSplit"]=function, ["sceneExists"]=function, ["centerPad"]=function, ["deviceExists"]=function, ["hasLines"]=function, ["log"]=function, ["LOG_INFO"]=3, ["fileExists"]=function, ["toJSON"]=function, ["toXML"]=function, ["setLogMarker"]=function, ["fromLines"]=function, ["fromXML"]=function, ["rgbToHSB"]=function, ["isJSON"]=function, ["toCelsius"]=function, ["toStr"]=function, ["urlEncode"]=function, ["print"]=function}, ["milliseconds"]=0, ["minutes"]=30, ["yday"]=38, ["time"]="14:30", ["wday"]=2}
voici quelques migration de os.date vers dz.time
os.date("%H") en dz.time.hour
os.date("%d-%m-%Y")
en dz.time.dateToDate(dz.time.rawDate,'yyyy-mm-dd','dd-mm-yyyy')
os.date('%d-%m-%Y', (os.time()+ 60*60*24))
en dz.time.dateToDate(dz.time.addDays(1).rawDate,'yyyy-mm-dd','dd-mm-yyyy')