eshan6704 commited on
Commit
87f0aa8
·
verified ·
1 Parent(s): c6a086e

Update common.py

Browse files
Files changed (1) hide show
  1. common.py +37 -0
common.py CHANGED
@@ -184,3 +184,40 @@ def wrap_html(content, title="Stock Data"):
184
  </body>
185
  </html>
186
  """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
184
  </body>
185
  </html>
186
  """
187
+ # ======================================================
188
+ # Scrollable HTML wrapper
189
+ # ======================================================
190
+ SCROLL_WRAP = """
191
+ <div style="
192
+ max-height: 80vh;
193
+ overflow-y: auto;
194
+ overflow-x: auto;
195
+ padding: 10px;
196
+ border: 1px solid #ccc;
197
+ border-radius: 6px;
198
+ ">
199
+ {{HTML}}
200
+ </div>
201
+ """
202
+
203
+ # ======================================================
204
+ # Date helpers
205
+ # ======================================================
206
+ def today_str():
207
+ return datetime.date.today().strftime("%d-%m-%Y")
208
+
209
+ def yesterday_str():
210
+ return (datetime.date.today() - datetime.timedelta(days=1)).strftime("%d-%m-%Y")
211
+
212
+ def last_year_date(d):
213
+ dt = datetime.datetime.strptime(d, "%d-%m-%Y")
214
+ new_dt = dt.replace(year=dt.year - 1)
215
+ return new_dt.strftime("%d-%m-%Y")
216
+
217
+ # ======================================================
218
+ # HTML wrapper
219
+ # ======================================================
220
+ def wrap(html):
221
+ if html is None:
222
+ return "<h3>No Data</h3>"
223
+ return SCROLL_WRAP.replace("{{HTML}}", html)