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

GetWeekBoundariesTimestampsAction   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 13
Duplicated Lines 0 %
Metric Value
wmc 2
dl 0
loc 13
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 12 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