diff options
author | Ron Yorston <rmy@pobox.com> | 2014-01-19 19:45:59 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2014-01-19 19:45:59 +0000 |
commit | ae1b385859a4d1db78f077478f7aeff904d84453 (patch) | |
tree | 783395daf070ed08e573e8dee85b1f8050cd3e40 /win32 | |
parent | f0e65513106dfb105f85260a6b47383325304e5e (diff) | |
download | busybox-w32-ae1b385859a4d1db78f077478f7aeff904d84453.tar.gz busybox-w32-ae1b385859a4d1db78f077478f7aeff904d84453.tar.bz2 busybox-w32-ae1b385859a4d1db78f077478f7aeff904d84453.zip |
date: emulate %e format
Diffstat (limited to 'win32')
-rw-r--r-- | win32/mingw.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/win32/mingw.c b/win32/mingw.c index 70a8cb611..bbeb3b8d8 100644 --- a/win32/mingw.c +++ b/win32/mingw.c | |||
@@ -804,6 +804,37 @@ char *strptime(const char *s UNUSED_PARAM, const char *format UNUSED_PARAM, stru | |||
804 | return NULL; | 804 | return NULL; |
805 | } | 805 | } |
806 | 806 | ||
807 | #undef strftime | ||
808 | size_t mingw_strftime(const char *buf, size_t max, const char *format, const struct tm *tm) | ||
809 | { | ||
810 | size_t ret; | ||
811 | const char *s; | ||
812 | char *t; | ||
813 | char *fmt = NULL; | ||
814 | |||
815 | /* | ||
816 | * Provide a simple-minded emulation of the '%e' format that Windows' | ||
817 | * strftime lacks. It won't work properly if there's more than one | ||
818 | * '%e' or if the user is playing games with '%'s. | ||
819 | */ | ||
820 | if ( (s=strstr(format, "%e")) != NULL ) { | ||
821 | fmt = xmalloc(strlen(format)+5); | ||
822 | strcpy(fmt, format); | ||
823 | t = strstr(fmt, "%e"); | ||
824 | if ( tm->tm_mday < 10 ) { | ||
825 | strcat(strcpy(t, " %#d"), s+2); | ||
826 | } | ||
827 | else { | ||
828 | t[1] = 'd'; | ||
829 | } | ||
830 | } | ||
831 | |||
832 | ret = strftime(buf, max, fmt ? fmt : format, tm); | ||
833 | free(fmt); | ||
834 | |||
835 | return ret; | ||
836 | } | ||
837 | |||
807 | #undef access | 838 | #undef access |
808 | int mingw_access(const char *name, int mode) | 839 | int mingw_access(const char *name, int mode) |
809 | { | 840 | { |