aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/Utils.php
diff options
context:
space:
mode:
authorVirtualTam <virtualtam@flibidi.net>2015-06-27 14:57:44 +0200
committerVirtualTam <virtualtam@flibidi.net>2015-07-09 00:44:19 +0200
commit9186ab95943b7c2467a0f27f30bed9db3c589b9d (patch)
treecfc8e4d2c8469ac16910c18d59a07b23d0348fbe /application/Utils.php
parent46d83c20d77276e9e94c54e31b29222f762e13dd (diff)
downloadShaarli-9186ab95943b7c2467a0f27f30bed9db3c589b9d.tar.gz
Shaarli-9186ab95943b7c2467a0f27f30bed9db3c589b9d.tar.zst
Shaarli-9186ab95943b7c2467a0f27f30bed9db3c589b9d.zip
LinkDB::filterDay(): check input date format
Signed-off-by: VirtualTam <virtualtam@flibidi.net>
Diffstat (limited to 'application/Utils.php')
-rw-r--r--application/Utils.php15
1 files changed, 15 insertions, 0 deletions
diff --git a/application/Utils.php b/application/Utils.php
index 82220bfc..a1e97b35 100644
--- a/application/Utils.php
+++ b/application/Utils.php
@@ -69,4 +69,19 @@ function sanitizeLink(&$link)
69 $link['description'] = escape($link['description']); 69 $link['description'] = escape($link['description']);
70 $link['tags'] = escape($link['tags']); 70 $link['tags'] = escape($link['tags']);
71} 71}
72
73/**
74 * Checks if a string represents a valid date
75 *
76 * @param string a string-formatted date
77 * @param format the expected DateTime format of the string
78 * @return whether the string is a valid date
79 * @see http://php.net/manual/en/class.datetime.php
80 * @see http://php.net/manual/en/datetime.createfromformat.php
81 */
82function checkDateFormat($format, $string)
83{
84 $date = DateTime::createFromFormat($format, $string);
85 return $date && $date->format($string) == $string;
86}
72?> 87?>