[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: kdelibs/kjs
From: Harri Porten <porten () kde ! org>
Date: 2005-04-17 16:50:23
Message-ID: 20050417165023.2B370488 () office ! kde ! org
[Download RAW message or body]
CVS commit by porten:
factor out date name parsing as suggested by Waldo. There's at least
one other place from where we'll call the function.
M +22 -11 date_object.cpp 1.96
--- kdelibs/kjs/date_object.cpp #1.95:1.96
@@ -719,4 +719,25 @@ double KJS::makeTime(struct tm *t, int m
}
+// returns 0-11 (Jan-Dec); -1 on failure
+static int findMonth(const char *monthStr)
+{
+ assert(monthStr);
+ char needle[4];
+ for (int i = 0; i < 3; ++i) {
+ if (!*monthStr)
+ return -1;
+ needle[i] = tolower(*monthStr++);
+ }
+ needle[3] = '\0';
+ const char *str = strstr(haystack, needle);
+ if (str) {
+ int position = str - haystack;
+ if (position % 3 == 0) {
+ return position / 3;
+ }
+ }
+ return -1;
+}
+
double KJS::KRFCDate_parseDate(const UString &_date)
{
@@ -759,16 +780,6 @@ double KJS::KRFCDate_parseDate(const USt
if ( isspace(*dateString) && dateString - wordStart >= 3 )
{
- monthStr[0] = tolower(*wordStart++);
- monthStr[1] = tolower(*wordStart++);
- monthStr[2] = tolower(*wordStart++);
- monthStr[3] = '\0';
//fprintf(stderr,"KJS::parseDate found word starting with '%s'\n", monthStr);
- const char *str = strstr(haystack, monthStr);
- if (str) {
- int position = str - haystack;
- if (position % 3 == 0) {
- month = position / 3; // Jan=00, Feb=01, Mar=02, ..
- }
- }
+ month = findMonth(wordStart);
while(*dateString && isspace(*dateString))
dateString++;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic