OSDN Git Service

Create new function to generate formatted timestamp with Japanese charactors and...
authorsakamocchi <sakamocchi@1ca29b6e-896d-4ea0-84a5-967f57386b96>
Fri, 28 Jan 2011 04:18:35 +0000 (04:18 +0000)
committersakamocchi <sakamocchi@1ca29b6e-896d-4ea0-84a5-967f57386b96>
Fri, 28 Jan 2011 04:18:35 +0000 (04:18 +0000)
git-svn-id: https://svn.sourceforge.jp/svnroot/nucleus-jp/nucleus-jp/trunk@1114 1ca29b6e-896d-4ea0-84a5-967f57386b96

utf8/nucleus/libs/ACTIONS.php
utf8/nucleus/libs/BLOG.php
utf8/nucleus/libs/COMMENTACTIONS.php
utf8/nucleus/libs/ITEMACTIONS.php
utf8/nucleus/libs/globalfunctions.php

index ab3a67b..8e6e380 100644 (file)
@@ -490,7 +490,7 @@ class ACTIONS extends BaseActions {
                        $format = '%d %B %Y';
                }
 
-               echo strftime($format,mktime(0,0,0,$m?$m:1,$d?$d:1,$y));
+               echo strftimejp($format,mktime(0,0,0,$m?$m:1,$d?$d:1,$y));
        }
 
        /**
index a922e1e..d8f1126 100755 (executable)
@@ -190,14 +190,14 @@ class BLOG {
                                        if ($old_date != 0) {
                                                $oldTS = strtotime($old_date);
                                                $manager->notify('PreDateFoot',array('blog' => &$this, 'timestamp' => $oldTS));
-                                               $tmp_footer = strftime(isset($template['DATE_FOOTER'])?$template['DATE_FOOTER']:'', $oldTS);
+                                               $tmp_footer = strftimejp(isset($template['DATE_FOOTER'])?$template['DATE_FOOTER']:'', $oldTS);
                                                $parser->parse($tmp_footer);
                                                $manager->notify('PostDateFoot',array('blog' => &$this, 'timestamp' => $oldTS));
                                        }
                                        $manager->notify('PreDateHead',array('blog' => &$this, 'timestamp' => $timestamp));
                                        // note, to use templatvars in the dateheader, the %-characters need to be doubled in
                                        // order to be preserved by strftime
-                                       $tmp_header = strftime((isset($template['DATE_HEADER']) ? $template['DATE_HEADER'] : null), $timestamp);
+                                       $tmp_header = strftimejp((isset($template['DATE_HEADER']) ? $template['DATE_HEADER'] : null), $timestamp);
                                        $parser->parse($tmp_header);
                                        $manager->notify('PostDateHead',array('blog' => &$this, 'timestamp' => $timestamp));
                                }
@@ -627,7 +627,7 @@ class BLOG {
                        );
 
                        $temp = TEMPLATE::fill($template['ARCHIVELIST_LISTITEM'],$data);
-                       echo strftime($temp,$current->itime);
+                       echo strftimejp($temp,$current->itime);
 
                }
 
index 155075a..1d687ba 100644 (file)
@@ -306,7 +306,7 @@ class COMMENTACTIONS extends BaseActions {
         * Parse templatevar time
         */
        function parse_time($format = '') {
-               echo strftime(
+               echo strftimejp(
                                ($format == '') ? $this->template['FORMAT_TIME'] : $format,
                                $this->currentComment['timestamp']
                        );
index 8f85186..e3698b5 100644 (file)
@@ -380,7 +380,7 @@ class ITEMACTIONS extends BaseActions {
          */\r
        function parse_time($format = '') {\r
                if (!isset($this->template['FORMAT_TIME'])) $this->template['FORMAT_TIME'] = '';
-               echo strftime($format ? $format : $this->template['FORMAT_TIME'],$this->currentItem->timestamp);\r
+               echo strftimejp($format ? $format : $this->template['FORMAT_TIME'],$this->currentItem->timestamp);\r
        }\r
 \r
        /**\r
index 1e51478..b9f4e5a 100755 (executable)
@@ -1782,7 +1782,7 @@ function formatDate($format, $timestamp, $defaultFormat, &$blog) {
                        return date('Y-m-d\TH:i:s', $timestamp) . $tz;\r
 \r
                default :\r
-                       return strftime($format ? $format : $defaultFormat, $timestamp);\r
+                       return strftimejp($format ? $format : $defaultFormat, $timestamp);\r
        }\r
 }\r
 \r
@@ -2443,4 +2443,18 @@ function cleanFileName($str) {
        \r
        return preg_replace("/[^a-z0-9-]/","_",$str).$ext;\r
 }\r
+\r
+/**\r
+ * generate correct timecode with the format includes Japanese charactors\r
+ * \r
+ * @param      String  $format standard format string. Allowd to include Japanese charactors\r
+ * @param      Integer $timestamp      Unix Timestamp formated integer\r
+ * @return     String  Formatted timestamp\r
+ */\r
+function strftimejp($format,$timestamp = ''){\r
+       return (setlocale(LC_CTYPE, 0) == 'Japanese_Japan.932')\r
+               ? iconv('CP932', _CHARSET, strftime(iconv(_CHARSET, 'CP932', $format),$timestamp))\r
+               : strftime($format,$timestamp)\r
+       ;\r
+}\r
 ?>
\ No newline at end of file