Exemple #1
0
 def _dt_to_ts_with_format(dt):
     ts = dt_to_ts_with_format(dt,
                               ts_format=rule['timestamp_format'])
     if 'timestamp_format_expr' in rule:
         # eval expression passing 'ts' and 'dt'
         return eval(rule['timestamp_format_expr'], {
             'ts': ts,
             'dt': dt
         })
     else:
         return ts
Exemple #2
0
def test_dt_to_ts_with_format2():
    assert dt_to_ts_with_format(dt('2021-02-01 12:30:00+00:00'),
                                '%d/%m/%Y %H:%M:%S') == '01/02/2021 12:30:00'
Exemple #3
0
def test_dt_to_ts_with_format3():
    assert dt_to_ts_with_format(
        '2021-02-01 12:30:00+00:00',
        '%d/%m/%Y %H:%M:%S') == '2021-02-01 12:30:00+00:00'
Exemple #4
0
def test_dt_to_ts_with_format1():
    assert dt_to_ts_with_format(dt('2021-02-01 12:30:00+00:00'),
                                '%Y/%m/%d %H:%M:%S') == '2021/02/01 12:30:00'