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
|
#! /usr/bin/env python3
#===============================
#
# timesheet
#
# This schedule is based on
# https://github.com/sbstjn/timesheet.js.git
#
# 2021/02/08 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
#===============================
import schedule
import datetime
class timesheet(schedule.schedule):
def print(self):
color = ['lorem', 'ipsum', 'dolor', 'default']
txt_b = """
<html>
<link rel="stylesheet" type="text/css" href="../scripts/timesheet.min.css">
<script type="text/javascript" src="../scripts/timesheet.min.js"></script>
<h1>PeriPeri Schedule</h1>
<div id="timesheet"></div>
<script>
"""
txt_e = """
</script>
</html>
"""
txt = "new Timesheet('timesheet', "
date_s = datetime.datetime(9999, 12, 31, 10, 0, 0)
date_e = datetime.datetime(1000, 1, 1, 10, 0, 0)
# check earliest/latest date
for lst in self.list:
ds = datetime.datetime.strptime(lst[0], "%m/%Y")
de = datetime.datetime.strptime(lst[1], "%m/%Y")
if ds < date_s:
date_s = ds
if (de > date_e):
date_e = de
txt += "{}, {}, [".format(date_s.strftime("%Y"),
date_e.strftime("%Y"))
c = 0
for lst in self.list:
txt += "['{}', '{}', '{}', '{}'],".\
format(lst[0], lst[1], lst[2], color[c])
c += 1
if (c >= len(color)):
c = 0
txt += "]);"
print(txt_b)
print(txt)
print(txt_e)
#====================================
#
# As command
#
#====================================
if __name__=='__main__':
timesheet().print()
|