GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Pull Request — v1 (#16)
by Maksim
03:39
created

unix_timestamp_today()   A

Complexity

Conditions 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1.125

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
dl 0
loc 10
ccs 1
cts 2
cp 0.5
crap 1.125
rs 9.4285
c 1
b 0
f 0
1
# -*- coding: utf-8 -*-
2
3 1
import datetime
4
5 1
import arrow
6
7
8 1
def unix_timestamp_today(tz=None):
9
	"""
10
	Returns unix timestamp for TODAY (00:00) in ``tz`` timezone (UTC by default)
11
12
	:param tz: Timezone, defaults to None (UTC)
13
	:type tz: datetime.tzinfo, optional
14
	:returns: Unix-timestamp (seconds) for today
15
	:rtype: int
16
	"""
17
	return arrow.get(tz).floor('day').timestamp
18
19
20 1
def timestamp_and_seconds2datetime(ts, sec=0):
21
22 1
	if ts is None:
23 1
		return None
24 1
	if sec is None:
25 1
		sec = 0
26
27 1
	dd = arrow.get(int(ts) + int(sec))
28 1
	return dd.datetime
29
30
31 1
def datetime2timestamp_and_seconds(dt):
32 1
	if not isinstance(dt, datetime.datetime):
33 1
		raise TypeError('dt', 'datetime.datetime expected!')
34
35 1
	adt = arrow.get(dt)
36
37 1
	ts = adt.floor('day').timestamp
38 1
	sec = adt.timestamp - ts
39 1
	return ts, sec
40
41
42 1
def add_limit_offset_to_query_string(limit, offset, qs):
43 1
	if limit is not None:
44
		qs['limit'] = limit
45
46 1
	if offset is not None:
47
		qs['offset'] = offset
48
49
	return qs
50