Github user kakaxi3019 commented on a diff in the pull request:
https://github.com/apache/trafodion/pull/1632#discussion_r201892154
--- Diff: core/sql/exp/exp_datetime.cpp ---
@@ -3294,6 +3338,39 @@ convertMonthToStr(Lng32 value, char *&result, UInt32 width)
result += width;
}
+static void
+convertDayOfWeekToStr(Lng32 value, char *&result, NABoolean bAbbreviation, UInt32
width)
+{
+ const char* dayofweek[] =
+ {
+ "SUNDAY ",
+ "MONDAY ",
+ "TUESDAY ",
+ "WEDNESDAY",
+ "THURSDAY ",
+ "FRIDAY ",
+ "SATURDAY "
+ };
+
+ const char* dayofweek_abb[] =
+ {
+ "SUN",
+ "MON",
+ "TUE",
+ "WED",
+ "THU",
+ "FRI",
+ "SAT"
+ };
+
+ if (bAbbreviation)
+ strcpy(result, dayofweek_abb[value-1]);
+ else
+ strcpy(result, dayofweek[value-1]);
+ // Update result pointer to point to end of string.
+ result += width;
--- End diff --
Yes. The string length is always 3 or 9, so i assign the value for width.
For example
strlen("SUNDAY")=6, but strlen("WEDNESDAY")=9.
so the length will always be 9.
But here "SUNDAY "(with 3 whitespace), so your suggestion is good, thank you!
---
|