diff options
author | blythe%netscape.com <devnull@localhost> | 2002-02-12 22:23:11 +0000 |
---|---|---|
committer | blythe%netscape.com <devnull@localhost> | 2002-02-12 22:23:11 +0000 |
commit | c928b7d7bb9004c862538df54edaf3a15426382b (patch) | |
tree | 2386a30773cfaaef30af0e64bf541fd1d4787396 | |
parent | 499e4015b958f1f5116916aa1bcf8c2aeff58abd (diff) | |
download | nspr-hg-c928b7d7bb9004c862538df54edaf3a15426382b.tar.gz |
finish strftime for WinCE
-rw-r--r-- | pr/src/md/windows/w32time.c | 211 |
1 files changed, 197 insertions, 14 deletions
diff --git a/pr/src/md/windows/w32time.c b/pr/src/md/windows/w32time.c index 918908fb..cb8df7b7 100644 --- a/pr/src/md/windows/w32time.c +++ b/pr/src/md/windows/w32time.c @@ -471,43 +471,226 @@ size_t Winstrftime(char *strDest, size_t maxsize, const char *format, const stru } break; case 'm': - PR_ASSERT(0); + { + int getRes = 0; + + /* + * Month in decimal. + */ + traverse++; + getRes = GetDateFormatW(LOCALE_USER_DEFAULT, 0, &sysTime, (PR_TRUE == poundOutput) ? _T("M") : _T("MM"), buf, sizeof(buf) / sizeof(WCHAR)); + if(0 != getRes) + { + helper_Winstrftime(buf, &outDst, &outMax, &errorOut, &hadEnoughSpace, *traverse); + } + else + { + errorOut = PR_TRUE; + } + } break; case 'M': - PR_ASSERT(0); + { + int getRes = 0; + + /* + * Minute in decimal. + */ + traverse++; + getRes = GetTimeFormatW(LOCALE_USER_DEFAULT, 0, &sysTime, (PR_TRUE == poundOutput) ? _T("m") : _T("mm"), buf, sizeof(buf) / sizeof(WCHAR)); + if(0 != getRes) + { + helper_Winstrftime(buf, &outDst, &outMax, &errorOut, &hadEnoughSpace, *traverse); + } + else + { + errorOut = PR_TRUE; + } + } break; case 'p': - PR_ASSERT(0); + { + int getRes = 0; + + /* + * 12 hour indicator. + */ + traverse++; + getRes = GetTimeFormatW(LOCALE_USER_DEFAULT, 0, &sysTime, _T("tt"), buf, sizeof(buf) / sizeof(WCHAR)); + if(0 != getRes) + { + helper_Winstrftime(buf, &outDst, &outMax, &errorOut, &hadEnoughSpace, *traverse); + } + else + { + errorOut = PR_TRUE; + } + } break; case 'S': - PR_ASSERT(0); + { + int getRes = 0; + + /* + * Second in decimal. + */ + traverse++; + getRes = GetTimeFormatW(LOCALE_USER_DEFAULT, 0, &sysTime, (PR_TRUE == poundOutput) ? _T("s") : _T("ss"), buf, sizeof(buf) / sizeof(WCHAR)); + if(0 != getRes) + { + helper_Winstrftime(buf, &outDst, &outMax, &errorOut, &hadEnoughSpace, *traverse); + } + else + { + errorOut = PR_TRUE; + } + } break; case 'U': - PR_ASSERT(0); + { + int weekOfYear = 0; + int dayAdjust = convertTM.tm_yday; + + /* + * Week of year in decimal. + * Sunday as first day. + */ + traverse++; + if(dayAdjust >= convertTM.tm_wday) + { + dayAdjust -= convertTM.tm_wday; + } + else + { + dayAdjust = 0; + } + + weekOfYear = dayAdjust / 7; + + wsprintfW(buf, (PR_TRUE == poundOutput) ? _T("d") : _T(".2d"), weekOfYear); + helper_Winstrftime(buf, &outDst, &outMax, &errorOut, &hadEnoughSpace, *traverse); + } break; case 'w': - PR_ASSERT(0); + { + /* + * Weekday as decimal. + */ + traverse++; + wsprintfW(buf, _T("d"), convertTM.tm_wday); + helper_Winstrftime(buf, &outDst, &outMax, &errorOut, &hadEnoughSpace, *traverse); + } break; case 'W': - PR_ASSERT(0); + { + int weekOfYear = 0; + int dayOfWeek = convertTM.tm_wday; + int dayAdjust = convertTM.tm_yday; + + /* + * Week of year in decimal. + * Monday as first day. + */ + traverse++; + if(0 == dayOfWeek) + { + dayOfWeek = 6; + } + else + { + dayOfWeek--; + } + if(dayAdjust >= dayOfWeek) + { + dayAdjust -= dayOfWeek; + } + else + { + dayAdjust = 0; + } + + weekOfYear = dayAdjust / 7; + + wsprintfW(buf, (PR_TRUE == poundOutput) ? _T("d") : _T(".2d"), weekOfYear); + helper_Winstrftime(buf, &outDst, &outMax, &errorOut, &hadEnoughSpace, *traverse); + } break; case 'x': - PR_ASSERT(0); + { + int getRes = 0; + + /* + * Date representation for locale. + */ + traverse++; + getRes = GetDateFormatW(LOCALE_USER_DEFAULT, (PR_TRUE == poundOutput) ? DATE_LONGDATE : DATE_SHORTDATE, &sysTime, NULL, buf, sizeof(buf) / sizeof(WCHAR)); + if(0 != getRes) + { + helper_Winstrftime(buf, &outDst, &outMax, &errorOut, &hadEnoughSpace, *traverse); + } + else + { + errorOut = PR_TRUE; + } + } break; case 'X': - PR_ASSERT(0); + { + int getRes = 0; + + /* + * Time representation for locale. + */ + traverse++; + getRes = GetTimeFormatW(LOCALE_USER_DEFAULT, 0, &sysTime, NULL, buf, sizeof(buf) / sizeof(WCHAR)); + if(0 != getRes) + { + helper_Winstrftime(buf, &outDst, &outMax, &errorOut, &hadEnoughSpace, *traverse); + } + else + { + errorOut = PR_TRUE; + } + } break; case 'y': - PR_ASSERT(0); + { + /* + * Year without century in decimal. (00-99) + */ + traverse++; + wsprintfW(buf, (PR_TRUE == poundOutput) ? _T("d") : _T(".2d"), convertTM.tm_year % 100); + helper_Winstrftime(buf, &outDst, &outMax, &errorOut, &hadEnoughSpace, *traverse); + } break; case 'Y': - PR_ASSERT(0); + { + int getRes = 0; + + /* + * Year with century, in decimal. + */ + getRes = GetDateFormatW(LOCALE_USER_DEFAULT, 0, &sysTime, _T("YYYY"), buf, sizeof(buf) / sizeof(WCHAR)); + if(0 != getRes) + { + helper_Winstrftime(buf, &outDst, &outMax, &errorOut, &hadEnoughSpace, *traverse); + } + else + { + errorOut = PR_TRUE; + } + } break; case 'z': - PR_ASSERT(0); - break; case 'Z': - PR_ASSERT(0); + { + /* + * Time zone name or abbreviation, or nothing if not known. + * We could possibly do something here with GetTimeZoneInformation, + * but is that relevant to the tm passed in? + */ + traverse++; + } break; case '%': { |