Austin Schuh | 208337d | 2022-01-01 14:29:11 -0800 | [diff] [blame] | 1 | #include "pico/util/datetime.h" |
| 2 | |
| 3 | #include <stdio.h> |
| 4 | |
| 5 | static const char *DATETIME_MONTHS[12] = { |
| 6 | "January", |
| 7 | "February", |
| 8 | "March", |
| 9 | "April", |
| 10 | "May", |
| 11 | "June", |
| 12 | "July", |
| 13 | "August", |
| 14 | "September", |
| 15 | "October", |
| 16 | "November", |
| 17 | "December" |
| 18 | }; |
| 19 | |
| 20 | static const char *DATETIME_DOWS[7] = { |
| 21 | "Sunday", |
| 22 | "Monday", |
| 23 | "Tuesday", |
| 24 | "Wednesday", |
| 25 | "Thursday", |
| 26 | "Friday", |
| 27 | "Saturday", |
| 28 | }; |
| 29 | |
| 30 | void datetime_to_str(char *buf, uint buf_size, const datetime_t *t) { |
| 31 | snprintf(buf, |
| 32 | buf_size, |
| 33 | "%s %d %s %d:%02d:%02d %d", |
| 34 | DATETIME_DOWS[t->dotw], |
| 35 | t->day, |
| 36 | DATETIME_MONTHS[t->month - 1], |
| 37 | t->hour, |
| 38 | t->min, |
| 39 | t->sec, |
| 40 | t->year); |
| 41 | }; |