42 lines
1.3 KiB
Python
42 lines
1.3 KiB
Python
from src.tools.str import int_to_str
|
|
|
|
MONTHS = ['janvier','février','mars','avril','mai','juin','juillet','aout','septembre','octobre','novembre','decembre']
|
|
WEEKDAY = ['lundi','mardi','mercredi','jeudi','vendredi','samedi','dimanche']
|
|
|
|
def get_time(date):
|
|
hour = date.hour
|
|
minute = date.minute
|
|
if minute == 40 or minute >= 50:
|
|
hour = hour + 1
|
|
minute = 60 - minute
|
|
return 'il est '+format_hour(hour)+' moins '+str(minute)
|
|
elif minute == 45:
|
|
return 'il est '+format_hour(hour+1)+' moins le quart'
|
|
elif minute == 15:
|
|
return 'il est '+format_hour(hour+1)+' et quart'
|
|
else:
|
|
return 'il est '+format_hour(hour)+' '+str(minute)
|
|
return
|
|
|
|
def get_date(date):
|
|
week_day = date.weekday()
|
|
day = date.day
|
|
month = date.month
|
|
year = date.year
|
|
return 'Nous somme le '+format_weekday(week_day)+' '+str(day)+' '+format_month(month)+' '+str(year)
|
|
#self.yoda.say('Nous somme le '+str(week_day)+' '+str(day)+' '+str(month)+' '+str(year))
|
|
|
|
def format_hour(hour):
|
|
if hour == 12:
|
|
return 'midi'
|
|
elif hour == 24 or hour == 0:
|
|
return 'minuit'
|
|
|
|
return int_to_str(hour, 'f') + ' heure'
|
|
|
|
def format_month(month):
|
|
return MONTHS[month - 1]
|
|
|
|
def format_weekday(week_day):
|
|
return WEEKDAY[week_day]
|