|
34 | 34 |
|
35 | 35 | # system packages |
36 | 36 | from machine import I2C |
37 | | -from micropython import const |
| 37 | +try: |
| 38 | + from micropython import const |
| 39 | +except ImportError: |
| 40 | + def const(x): |
| 41 | + return x |
38 | 42 |
|
39 | 43 |
|
40 | 44 | class _Subscriptable(): |
@@ -109,8 +113,8 @@ def datetime(self) -> Tuple[int, int, int, int, int, int, int, int]: |
109 | 113 | """ |
110 | 114 | Get the current datetime |
111 | 115 |
|
112 | | - (2023, 4, 18, 0, 10, 34, 4, 0) |
113 | | - y, m, d, |
| 116 | + (2023, 4, 18, 0, 10, 34, 4, 108) |
| 117 | + y, m, d, h, m, s, wd, yd |
114 | 118 |
|
115 | 119 | :returns: (year, month, day, hour, minute, second, weekday, yearday) |
116 | 120 | :rtype: Tuple[int, int, int, int, int, int, int, int] |
@@ -240,7 +244,7 @@ def yearday(self) -> int: |
240 | 244 | :returns: Yearday of RTC |
241 | 245 | :rtype: int |
242 | 246 | """ |
243 | | - return self.datetime[6] |
| 247 | + return self.datetime[7] |
244 | 248 |
|
245 | 249 | def is_leap_year(self, year: int) -> bool: |
246 | 250 | """ |
@@ -275,7 +279,7 @@ def day_of_year(self, year: int, month: int, day: int) -> int: |
275 | 279 | for x in range(1, month): |
276 | 280 | days16 += month_days[x - 1] |
277 | 281 |
|
278 | | - if month == 2 and self.is_leap_year(year=year): |
| 282 | + if month >= 2 and self.is_leap_year(year=year): |
279 | 283 | days16 += 1 |
280 | 284 |
|
281 | 285 | return days16 |
|
0 commit comments