JDManipulator.py
2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import datetime
import time
from decimal import *
JD_VALUE = 86400
TIMESTAMP_JD = 2440587.500000
DAILY_SECOND = 1 / 86400
def JulianSeconds(value):
return (Decimal(value * DAILY_SECOND))
def getPreciseCurrentTime():
return (Decimal(getCurrentTime()))
def getPreciseNightStart():
return (Decimal(getNightStart()))
def getPreciseNightEnd():
return (Decimal(getNightEnd()))
def secondsToJulianDate(time_seconds):
return (time_seconds / 86400 + TIMESTAMP_JD)
def julianDateToSeconds(time_julian):
return ((time_julian - TIMESTAMP_JD) * 86400)
def getCurrentTime():
current_time = datetime.datetime.now()
return (time.mktime(current_time.timetuple()))
def getNextDefaultNightStart():
current_time = datetime.datetime.now()
if (current_time.hour >= 18):
current_time += datetime.timedelta(days=1)
current_time = current_time.replace(hour=18, minute=0, second=0, microsecond=0)
return (time.mktime(current_time.timetuple()))
def getNextDefaultNightEnd():
current_time = datetime.datetime.now()
if (current_time.hour >= 18):
current_time += datetime.timedelta(days=2)
else:
current_time += datetime.timedelta(days=1)
current_time = current_time.replace(hour=6, minute=0, second=0, microsecond=0)
return (time.mktime(current_time.timetuple()))
def getDefaultNightStart():
current_time = datetime.datetime.now()
current_time = current_time.replace(hour=18, minute=0, second=0, microsecond=0)
return (time.mktime(current_time.timetuple()))
def getDefaultNightEnd():
current_time = datetime.datetime.now()
current_time += datetime.timedelta(days=1)
current_time = current_time.replace(hour=6, minute=0, second=0, microsecond=0)
return (time.mktime(current_time.timetuple()))
def datetimeToJulianDate(current_time):
return (time.mktime(current_time.timetuple()) / JD_VALUE + TIMESTAMP_JD)
''' TODO '''
def getNightStart():
return (getDefaultNightStart())
''' TODO '''
def getNightEnd():
return (getDefaultNightEnd())
''' TODO '''
def getNextNightStart():
return (getNextDefaultNightStart())
''' TODO '''
def getNextNightEnd():
return (getNextNightEnd())