Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Récupère l'heure et la date de Paris en temps réel
- function getParisDateTime()
- local url = "http://worldtimeapi.org/api/timezone/Europe/Paris"
- local response = http.get(url)
- local data = response.readAll()
- response.close()
- local time = textutils.unserializeJSON(data)
- local date = string.sub(time.datetime, 9, 10) .. "/" .. string.sub(time.datetime, 6, 7) .. "/" .. string.sub(time.datetime, 1, 4)
- local time = string.sub(time.datetime, 12, 19)
- return date, time
- end
- -- Fonction pour ajuster la taille d'affichage en fonction du nombre de moniteurs
- function adjustDisplaySize(monitor)
- local size = #peripheral.getNames("monitor")
- if size == 0 then
- size = 1
- end
- monitor.setTextScale(math.floor(4 / size))
- end
- -- Initialise le moniteur
- local monitor = peripheral.wrap("top")
- adjustDisplaySize(monitor)
- monitor.setTextColor(colors.white)
- -- Boucle principale : affiche la date et l'heure de Paris en temps réel sur le moniteur
- while true do
- local date, time = getParisDateTime()
- monitor.clear()
- monitor.setCursorPos(1,1)
- monitor.write(date)
- monitor.setCursorPos(1,2)
- monitor.write(time)
- sleep(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment