You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2021/05/31 03:23:50 UTC

[GitHub] [incubator-doris] yangzhg commented on a change in pull request #5866: [Features]Add mysql last_day function support

yangzhg commented on a change in pull request #5866:
URL: https://github.com/apache/incubator-doris/pull/5866#discussion_r642187423



##########
File path: be/src/exprs/timestamp_functions.cpp
##########
@@ -608,6 +608,28 @@ DateTimeVal TimestampFunctions::time_round(FunctionContext* ctx, const DateTimeV
     return new_ts_val;
 }
 
+DateTimeVal TimestampFunctions::last_day(FunctionContext* ctx, const DateTimeVal& ts_val) {
+    if (ts_val.is_null) {
+        return DateTimeVal::null();
+    }
+    const DateTimeValue& ts_value = DateTimeValue::from_datetime_val(ts_val);
+    int last_days[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
+    int day ;
+    int year = ts_value.year();
+    int month = ts_value.month();
+    if((year % 4 == 0 && year % 100 !=0)||(year % 400 ==0 )) {

Review comment:
       Additional white space




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org