chaoswg.helpers.format_datetime_custom()   A
last analyzed

Complexity

Conditions 2

Size

Total Lines 4
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 2
nop 1
1
from datetime import datetime
2
3
from flask_babel import format_datetime, format_timedelta
4
5
6
def format_datetime_custom(value):
7
    if value is None:
8
        return 'Not yet'
9
    return format_datetime(value, 'dd.MM.yy HH:mm')
10
11
12
def format_timedelta_custom(value):
13
    if value is None:
14
        return 'Not yet'
15
    now = datetime.utcnow()
16
    return format_timedelta(value - now, granularity='day', add_direction=True)
17