Skip to content

Instantly share code, notes, and snippets.

@serge-eric-kalaga
Created February 10, 2025 10:34
Show Gist options
  • Save serge-eric-kalaga/2ae397bec3f2a2e6a48d0a83463cc87b to your computer and use it in GitHub Desktop.
Save serge-eric-kalaga/2ae397bec3f2a2e6a48d0a83463cc87b to your computer and use it in GitHub Desktop.
from datetime import datetime, timedelta
def seconds_until_midnight():
now = datetime.now()
# Calculer l'heure de minuit (00:00:00 du lendemain)
midnight = (now + timedelta(days=1)).replace(
hour=0, minute=0, second=0, microsecond=0
)
# Calculer le temps restant en secondes
return int((midnight - now).total_seconds())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment