Projet

Général

Profil

« Précédent | Suivant » 

Révision 1bcca449

Ajouté par Benjamin Dauvergne il y a plus de 10 ans

humantime: adapt datetime timezone before formating the first time

Voir les différences:

entrouvert/djommon/humantime/utils.py
7 7
def datetime2human(dt, include_time=False, days_limit=7):
8 8
    '''Format a datetime object for human consumption'''
9 9
    if isinstance(dt, datetime.datetime):
10
        dt = localtime(dt)
10 11
        time = dt.strftime('%H:%M')
11 12
    else:
12 13
        dt = datetime.datetime(year=dt.year, month=dt.month, day=dt.day,
13 14
                tzinfo=get_default_timezone())
15
        dt = localtime(dt)
14 16
        include_time = False
15
    dt = localtime(dt)
16 17
    today = datetime.date.today()
17 18
    yesterday = today - datetime.timedelta(days=1)
18 19
    subdate = dt.date()

Formats disponibles : Unified diff