aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/Utils.php
diff options
context:
space:
mode:
authorVirtualTam <tamisier.aurelien@gmail.com>2015-07-09 01:00:40 +0200
committerVirtualTam <tamisier.aurelien@gmail.com>2015-07-09 01:00:40 +0200
commit7f1dfd1c12a143b324fbe68213a49de0586febfa (patch)
treecfc8e4d2c8469ac16910c18d59a07b23d0348fbe /application/Utils.php
parent46d83c20d77276e9e94c54e31b29222f762e13dd (diff)
parent9186ab95943b7c2467a0f27f30bed9db3c589b9d (diff)
downloadShaarli-7f1dfd1c12a143b324fbe68213a49de0586febfa.tar.gz
Shaarli-7f1dfd1c12a143b324fbe68213a49de0586febfa.tar.zst
Shaarli-7f1dfd1c12a143b324fbe68213a49de0586febfa.zip
Merge pull request #251 from virtualtam/linkdb/date-format
LinkDB::filterDay(): check input date format
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?>