Skip to content

Commit 6e1304b

Browse files
authored
Merge pull request mouredev#7045 from neslarra/patch-63
Reto# 44 - python
2 parents 47f435f + 90b3ea3 commit 6e1304b

File tree

1 file changed

+14
-10
lines changed
  • Roadmap/44 - CUENTA ATRÁS MOUREDEV PRO/python

1 file changed

+14
-10
lines changed

Roadmap/44 - CUENTA ATRÁS MOUREDEV PRO/python/neslarra.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,38 +17,42 @@
1717
- Realiza la ejecución, si el lenguaje lo soporta, en
1818
un hilo independiente.
1919
"""
20-
from datetime import datetime as dt, timedelta as td
20+
from datetime import datetime as dt, timezone as tz
2121
from threading import Thread
22-
from os import system
22+
from os import system, name
2323
from time import sleep
2424

25-
END_TIME = dt.strptime('20241105111925', '%Y%m%d%H%M%S')
25+
END_TIME = dt.strptime('20241122112725', '%Y%m%d%H%M%S').replace(
26+
tzinfo=dt.now().astimezone().tzinfo).astimezone(tz.utc)
2627

2728

2829
class Clock(Thread):
2930
def run(self):
30-
while dt.now() < END_TIME:
31-
system("cls")
32-
current_time = END_TIME - dt.now()
31+
while dt.now(tz.utc) < END_TIME:
32+
if name == "posix":
33+
system("clear")
34+
else:
35+
system("cls")
36+
current_time = END_TIME - dt.now(tz.utc)
3337
days_left = current_time.days
3438
hours_left = current_time.seconds // 3600
35-
minutes_left = current_time.seconds // 60
39+
minutes_left = (current_time.seconds % 3600) // 60
3640
seconds_left = current_time.seconds - hours_left * 3600 - minutes_left * 60
3741
print(f"Faltan: {days_left} días, {hours_left} horas, {minutes_left} minutos, {seconds_left} segundos")
3842
sleep(1)
39-
print(f"TERMINADO: {END_TIME} {dt.now()}")
43+
print(f"TERMINADO: {END_TIME} {dt.now(tz.utc)}")
4044

4145

4246
class Counter(Thread):
4347
def run(self):
4448
count = 0
45-
while dt.now() < END_TIME:
49+
while dt.now(tz.utc) < END_TIME:
4650
count += 1
4751
print(f"Vamos contando {count}")
4852
sleep(1)
4953
print(f"Terminé de contar en {count}")
5054

5155

5256
Clock().start()
53-
sleep(0.3)
57+
sleep(0.5)
5458
Counter().start()

0 commit comments

Comments
 (0)