diff options
-rw-r--r-- | common/sys/time.c | 21 | ||||
-rw-r--r-- | include/cmsys.h | 9 |
2 files changed, 22 insertions, 8 deletions
diff --git a/common/sys/time.c b/common/sys/time.c index 8564b514..bf8164c9 100644 --- a/common/sys/time.c +++ b/common/sys/time.c @@ -39,7 +39,7 @@ int getHoroscope(int m, int d) /** * 23+1 bytes, "12/31/2007 00:00:00 Mon\0" */ -char * +const char* Cdate(const time4_t *clock) { time_t temp = (time_t)*clock; @@ -52,7 +52,7 @@ Cdate(const time4_t *clock) /** * 19+1 bytes, "12/31/2007 00:00:00\0" */ -char * +const char* Cdatelite(const time4_t *clock) { time_t temp = (time_t)*clock; @@ -65,7 +65,7 @@ Cdatelite(const time4_t *clock) /** * 10+1 bytes, "12/31/2007\0" */ -char * +const char* Cdatedate(const time4_t * clock) { time_t temp = (time_t)*clock; @@ -75,6 +75,19 @@ Cdatedate(const time4_t * clock) return cdate_buffer; } +/** + * 11+1 bytes, "12/31 10:01\0" + */ +const char* +Cdate_mdHM(const time4_t * clock) +{ + time_t temp = (time_t)*clock; + struct tm *mytm = localtime(&temp); + + strftime(cdate_buffer, sizeof(cdate_buffer), "%m/%d %H:%M", mytm); + return cdate_buffer; +} + #ifdef TIMET64 char * ctime4(const time4_t *clock) @@ -103,7 +116,7 @@ time4_t time4(time4_t *ptr) } #endif -char * +const char* my_ctime(const time4_t * t, char *ans, int len) { struct tm *tp; diff --git a/include/cmsys.h b/include/cmsys.h index 934ccd9d..abb66213 100644 --- a/include/cmsys.h +++ b/include/cmsys.h @@ -108,10 +108,11 @@ extern unsigned StringHash(const char *s); /* time.c */ extern int is_leap_year(int year); extern int getHoroscope(int m, int d); -extern char* Cdate(const time4_t *clock); -extern char* Cdatelite(const time4_t *clock); -extern char* Cdatedate(const time4_t * clock); -extern char* my_ctime(const time4_t * t, char *ans, int len); +extern const char* Cdate(const time4_t *clock); +extern const char* Cdatelite(const time4_t *clock); +extern const char* Cdatedate(const time4_t * clock); +extern const char * Cdate_mdHM(const time4_t * clock); +extern const char* my_ctime(const time4_t * t, char *ans, int len); #ifdef TIMET64 struct tm *localtime4(const time4_t *); time4_t time4(time4_t *); |