File: 0009-Added-strftime-method-to-fix-870.patch

package info (click to toggle)
gtg 0.6-12
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 9,492 kB
  • sloc: xml: 20,785; python: 17,657; sh: 158; makefile: 93
file content (29 lines) | stat: -rw-r--r-- 1,005 bytes parent folder | download
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
From: Andy <awc34@cornell.edu>
Date: Wed, 30 Nov 2022 10:31:30 -0500
Subject: Added strftime() method to fix #870

---
 GTG/core/dates.py | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/GTG/core/dates.py b/GTG/core/dates.py
index 80e8789..6cb0a6f 100644
--- a/GTG/core/dates.py
+++ b/GTG/core/dates.py
@@ -228,6 +228,16 @@ class Date:
         return (self.dt_by_accuracy(Accuracy.fuzzy),
                 other.dt_by_accuracy(Accuracy.fuzzy))
 
+    def strftime(self,format: str) -> str:
+        if isinstance(self.dt_value, (date,datetime)):
+            return self.dt_value.strftime(format)
+        else:
+            # If dt_value is not an instance of datetime.date or datetime.datetime, use self.date() to get one of those
+            # and call its strftime() method
+            temp_date = self.date()
+            return temp_date.strftime(format)
+
+
     def __add__(self, other):
         a, b = self._cast_for_operation(other, is_comparison=False)
         return a + b