splitbrain / dokuwiki-plugin-data

Add and query structured data in your DokuWiki
http://www.dokuwiki.org/plugin:data
GNU General Public License v2.0
50 stars 34 forks source link

[Feature Request] Use date format set by dformat #207

Open SFITCS opened 7 years ago

SFITCS commented 7 years ago

Priority low. I'm happy to keep hacking this feature into releases. By default the plugin uses yy-mm-dd date format, regardless of what format is set in $conf['dformat']. Unfortunately this does not suit Australia as we use the dd-mm-yy format. I don't know how to automate the process of supporting the format set by $conf['dformat'], but it's currently a simple hack to force dd-mm-yy.

diff -r Original/data/helper.php Modified/data/helper.php
119,120c119,120
<                 if(preg_match('/^(\d\d\d\d)-(\d\d?)-(\d\d?)$/', $value, $m)) {
<                     return sprintf('%d-%02d-%02d', $m[1], $m[2], $m[3]);
---
>                 if(preg_match('/^(\d\d?)-(\d\d?)-(\d\d\d\d)$/', $value, $m)) {
>                     return sprintf('%02d-%02d-%d', $m[1], $m[2], $m[3]);
512c512
<         $data['sql'] = str_replace('%now%', dformat(null, '%Y-%m-%d'), $data['sql']);
---
>         $data['sql'] = str_replace('%now%', dformat(null, '%d-%m-%Y'), $data['sql']);
diff -r Original/data/script.js Modified/data/script.js
6c6
<         dateFormat: "yy-mm-dd",
---
>         dateFormat: "dd-mm-yy",