Vish2005 commited on
Commit
a1ecdea
·
1 Parent(s): d112e03

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -5
app.py CHANGED
@@ -6,21 +6,40 @@ from datetime import datetime
6
 
7
  pq = PriorityQueue(maxsize = None)
8
 
9
- date_format = '%m-%d-%Y'
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
 
11
  def add_elem(date_str, item_name):
12
 
13
  cur_date = datetime.strptime(date_str, date_format)
14
 
15
- pq.push((cur_date, item_name))
16
 
17
- return pq
18
 
19
  def pop():
20
 
21
  pq.get()
22
 
23
- return pq
24
 
25
 
26
  iface = gr.Interface(
@@ -28,7 +47,7 @@ iface = gr.Interface(
28
  inputs=["text", "text"],
29
  outputs="text",
30
  title="Add Work",
31
- description="Enter Date in MM-DD-YYYY and Name of Assignment",
32
  )
33
 
34
  iface.launch()
 
6
 
7
  pq = PriorityQueue(maxsize = None)
8
 
9
+ date_format = '%m-%d-%Y at %H:%M'
10
+
11
+ def writer(pair):
12
+
13
+ final = pair[1] + ' is due on '
14
+ final += f'{pair[0].month:02}-{pair[0].day:02}-{pair[0].year} at '
15
+ final += f'{pair[0].hour:02}:{pair[0].minute:02}'
16
+
17
+ return final
18
+
19
+
20
+ def string_rep(pq):
21
+
22
+ work = ""
23
+
24
+ for element in pq.queue:
25
+
26
+ work += writer(element) + '\n'
27
+
28
+ return work
29
 
30
  def add_elem(date_str, item_name):
31
 
32
  cur_date = datetime.strptime(date_str, date_format)
33
 
34
+ pq.put((cur_date, item_name))
35
 
36
+ return string_rep(pq)
37
 
38
  def pop():
39
 
40
  pq.get()
41
 
42
+ return string_rep(pq)
43
 
44
 
45
  iface = gr.Interface(
 
47
  inputs=["text", "text"],
48
  outputs="text",
49
  title="Add Work",
50
+ description="Enter Date in 'MM-DD-YYYY at HH:MM' and Name of Assignment",
51
  )
52
 
53
  iface.launch()