From 5fe45f7b101e6bca22f16bc04291e7ea8b6da0d8 Mon Sep 17 00:00:00 2001
From: Uma <uma.s@vtiger.com>
Date: Wed, 2 Sep 2020 12:40:38 +0530
Subject: [PATCH] Fixes #1471 Date format with update task has been addressed

---
 .../Settings/Workflows/actions/TaskAjax.php   |  7 ++--
 vtlib/Vtiger/Functions.php                    | 32 ++++++++++++-------
 2 files changed, 26 insertions(+), 13 deletions(-)

diff --git a/modules/Settings/Workflows/actions/TaskAjax.php b/modules/Settings/Workflows/actions/TaskAjax.php
index f0c6f6c3d..9af3153d1 100644
--- a/modules/Settings/Workflows/actions/TaskAjax.php
+++ b/modules/Settings/Workflows/actions/TaskAjax.php
@@ -116,10 +116,13 @@ class Settings_Workflows_TaskAjax_Action extends Settings_Vtiger_IndexAjax_View
 							$result->emit();
 							return;
 						}
-					}
+					}else if($mappingInfo['valuetype'] == 'rawtext' && Vtiger_Functions::isDateValue($mappingInfo['value'])) {
+                                            $mappingInfo['value'] = DateTimeField::convertToDBFormat($mappingInfo['value']);
+                                            $fieldMapping[$key] = $mappingInfo;
+                                        }
 				}
 			}
-
+                        $taskObject->field_value_mapping = Zend_Json::encode($fieldMapping);
 			$taskType = get_class($taskObject);
 			if ($taskType === 'VTCreateEventTask' || $taskType === 'VTCreateTodoTask') {
 				if($taskType === 'VTCreateEventTask') {
diff --git a/vtlib/Vtiger/Functions.php b/vtlib/Vtiger/Functions.php
index 245cf42c2..4762ebf70 100644
--- a/vtlib/Vtiger/Functions.php
+++ b/vtlib/Vtiger/Functions.php
@@ -1243,17 +1243,27 @@ class Vtiger_Functions {
 	 * @return boolean Returns true if $value is date else returns false
 	 */
 	static function isDateValue($value) {
-		$valueParts = explode('-', $value);
-		if (count($valueParts) == 3 && (strlen($valueParts[0]) == 4 || strlen($valueParts[1]) == 4 || strlen($valueParts[2]) == 4)) {
-			$time = strtotime($value);
-			if ($time && $time > 0) {
-				return true;
-			} else {
-				return false;
-			}
-		} else {
-			return false;
-		}
+            $value = trim($value);
+            $delim = array('/','.');
+            foreach ($delim as $delimiter){
+                    $x = strpos($value, $delimiter);
+                    if($x === false) continue;
+                    else{
+                            $value=str_replace($delimiter, '-', $value);
+                            break;
+                    }
+            }
+            $valueParts = explode('-', $value);
+            if (count($valueParts) == 3 && (strlen($valueParts[0]) == 4 || strlen($valueParts[1]) == 4 || strlen($valueParts[2]) == 4)) {
+                    $time = strtotime($value);
+                    if ($time && $time > 0) {
+                            return true;
+                    } else {
+                            return false;
+                    }
+            } else {
+                    return false;
+            }
 	}
 
 	/**
-- 
GitLab