:: DateMacro[widget]
<<widget 'date'>>
    <<set _date to _args[0].toString().padStart(2, '0')>>
    <<set _date += '.'+_args[1].toString().padStart(2, '0')>>
    <<set _date += '.'+_args[2].toString().padStart(4, '19')>>
    <<print _date>>
<</widget>>

<<widget 'datetime'>>
    <<date `_args[0].getUTCDate()` `_args[0].getUTCMonth()+1` `_args[0].getUTCFullYear()`>>, <<time_print _args[0]>>
<</widget>>

<<widget 'datetime_current'>>
    <<time_current>> <<weekday $time.weekday>> <<date $time.day $time.month $time.year>>
<</widget>>

<<widget 'duration'>>
    <<set _duration to _args[0]>>
    <<if _duration < 1>>
        a few seconds
    <<elseif _duration == 1>>
        1 minute
    <<elseif _duration < 120>>
        _duration minutes
    <<elseif _duration < 2880>> <!-- 48 hours -->
        <<print Math.round(_duration / 60)>> hours
    <<elseif _duration < 64800>> <!-- 45 days -->
        <<print Math.round(_duration / 1440)>> days
    <<elseif _duration < 1051920>> <!-- 24 months -->
        <<print Math.round(_duration / 43200)>> months
    <<else>>
        <<print Math.round(_duration / 525960)>> years
    <</if>>

<</widget>>

<<widget 'time_print'>>
    <<if _args[0] instanceof Date>>
        <<set _tp_hour = _args[0].getUTCHours()>>
        <<set _tp_minutes=_args[0].getUTCMinutes()>>
    <<else>>
        <<set _tp_hour = _args[0]>>
        <<set _tp_minutes = _args[1]>>
    <</if>>
    <<print _tp_hour.toString().padStart(2, '0')>>:<<print _tp_minutes.toString().padStart(2, '0')>>
<</widget>>

<<widget 'time_current'>>
    <<time_print $time.hour $time.minutes>>
<</widget>>

<<widget 'weekday'>>
    <<switch _args[0]>>
        <<case 1>>
            Monday
        <<case 2>>
            Tuesday
        <<case 3>>
            Wednesday
        <<case 4>>
            Thursday
        <<case 5>>
            Friday
        <<case 6>>
            Saturday
        <<case 7>>
            Sunday
    <</switch>>
<</widget>>
