Completed
Pull Request — master (#349)
by Tomaz
02:59
created

GetWeekBoundariesTimestampsAction.run()   A

Complexity

Conditions 2

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 12
rs 9.4286
cc 2
1
import datetime
2
3
import arrow
4
5
from st2common.util import isotime
6
from st2actions.runners.pythonrunner import Action
7
8
9
class GetWeekBoundariesTimestampsAction(Action):
10
    def run(self, date=None):
11
        if date:
12
            dt = isotime.parse(date)
13
            dt = arrow.get(dt)
14
        else:
15
            # No date provided, use current date
16
            dt = arrow.utcnow()
17
18
        start_timestamp = dt.floor('week').timestamp
19
        end_timestamp = dt.ceil('week').timestamp
20
21
        return start_timestamp, end_timestamp
22