fmsystem-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Fmsystem-commits] [10014] controller: use dateformat from userprefs


From: Sigurd Nes
Subject: [Fmsystem-commits] [10014] controller: use dateformat from userprefs
Date: Thu, 20 Sep 2012 10:26:09 +0000

Revision: 10014
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=10014
Author:   sigurdne
Date:     2012-09-20 10:26:09 +0000 (Thu, 20 Sep 2012)
Log Message:
-----------
controller: use dateformat from userprefs

Modified Paths:
--------------
    trunk/controller/inc/class.uicheck_list.inc.php
    trunk/controller/inc/component/class.check_list_status_manager.inc.php
    trunk/controller/inc/helper/class.date_helper.inc.php
    trunk/controller/inc/model/class.control.inc.php

Modified: trunk/controller/inc/class.uicheck_list.inc.php
===================================================================
--- trunk/controller/inc/class.uicheck_list.inc.php     2012-09-20 09:16:01 UTC 
(rev 10013)
+++ trunk/controller/inc/class.uicheck_list.inc.php     2012-09-20 10:26:09 UTC 
(rev 10014)
@@ -364,18 +364,26 @@
                        $completed_date = phpgw::get_var('completed_date', 
'string');
                        $comment = phpgw::get_var('comment', 'string');
                                        
-                       $deadline_date_ts = 
date_helper::get_timestamp_from_date( $deadline_date, "d/m-Y" );
+                       $dateformat = 
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
+
+                       $deadline_date_ts = 
date_helper::get_timestamp_from_date( $deadline_date, $dateformat );
                        
-                       if($planned_date != ''){
-                               $planned_date_ts = 
date_helper::get_timestamp_from_date( $planned_date, "d/m-Y" );
-                       }else{
+                       if($planned_date != '')
+                       {
+                               $planned_date_ts = 
date_helper::get_timestamp_from_date( $planned_date, $dateformat );
+                       }
+                       else
+                       {
                                $planned_date_ts = 0;
                        } 
                        
-                       if($completed_date != ''){
-                               $completed_date_ts = 
date_helper::get_timestamp_from_date( $completed_date, "d/m-Y" );
+                       if($completed_date != '')
+                       {
+                               $completed_date_ts = 
date_helper::get_timestamp_from_date( $completed_date, $dateformat );
                                $status = controller_check_list::STATUS_DONE;
-                       }else{
+                       }
+                       else
+                       {
                                $completed_date_ts = 0;
                        }               
 

Modified: trunk/controller/inc/component/class.check_list_status_manager.inc.php
===================================================================
--- trunk/controller/inc/component/class.check_list_status_manager.inc.php      
2012-09-20 09:16:01 UTC (rev 10013)
+++ trunk/controller/inc/component/class.check_list_status_manager.inc.php      
2012-09-20 10:26:09 UTC (rev 10014)
@@ -86,8 +86,9 @@
                                $check_list_status_info->set_check_list_id( 
$this->check_list->get_id() );
                        }
                        
+                       $dateformat = 
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
                        $check_list_status_info->set_control_id( 
$this->check_list->get_control_id() );
-                       $check_list_status_info->set_deadline_date_txt( 
date("d/m-Y", $this->check_list->get_deadline()) );
+                       $check_list_status_info->set_deadline_date_txt( 
date($dateformat, $this->check_list->get_deadline()) );
                        $check_list_status_info->set_deadline_date_ts( 
$this->check_list->get_deadline() );
                        $check_list_status_info->set_type( $this->type );
                        

Modified: trunk/controller/inc/helper/class.date_helper.inc.php
===================================================================
--- trunk/controller/inc/helper/class.date_helper.inc.php       2012-09-20 
09:16:01 UTC (rev 10013)
+++ trunk/controller/inc/helper/class.date_helper.inc.php       2012-09-20 
10:26:09 UTC (rev 10014)
@@ -1,24 +1,29 @@
 <?php
-       class date_helper {
+       class date_helper
+       {
        
-       public function __construct(){}
+               public function __construct(){}
                
-       public static function get_timestamp_from_date( $date_string, $format  
){
-               
-               if( $format == "d/m-Y" ){
-                       $pos_day = strpos($date_string, "/"); 
-                       $day = date_helper::substring($date_string, 0, 
$pos_day);
+               public static function get_timestamp_from_date( $date_string, 
$format  )
+               {
+                       $dateformat = 
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
+
+                       if( $format == $dateformat )
+                       {
+                               $pos_day = strpos($date_string, "/"); 
+                               $day = date_helper::substring($date_string, 0, 
$pos_day);
                        
-                       $pos_month = strpos($date_string, "-");
-                       $month = date_helper::substring($date_string, 
$pos_day+1, $pos_month);
+                               $pos_month = strpos($date_string, "-");
+                               $month = date_helper::substring($date_string, 
$pos_day+1, $pos_month);
                        
-                       $year = date_helper::substring($date_string, 
$pos_month+1, strlen($date_string));
+                               $year = date_helper::substring($date_string, 
$pos_month+1, strlen($date_string));
 
-                       return mktime(0, 0, 0, $month, $day, $year);
+                               return mktime(0, 0, 0, $month, $day, $year);
+                       }
                }
-       }
        
-       public function substring($string, $from, $to){
-       return substr($string, $from, $to - $from);
+               public function substring($string, $from, $to)
+               {
+               return substr($string, $from, $to - $from);
+               }
        }
-}
\ No newline at end of file

Modified: trunk/controller/inc/model/class.control.inc.php
===================================================================
--- trunk/controller/inc/model/class.control.inc.php    2012-09-20 09:16:01 UTC 
(rev 10013)
+++ trunk/controller/inc/model/class.control.inc.php    2012-09-20 10:26:09 UTC 
(rev 10014)
@@ -273,19 +273,21 @@
                
                public function populate()
                {
+                               $dateformat = 
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
+
                                
$this->set_title(phpgw::get_var('title','string'));
                                
$this->set_description(phpgw::get_var('description','html'));
                                
                                if(phpgw::get_var('start_date','string') != '')
                                {
-                                       $start_date_ts = 
date_helper::get_timestamp_from_date( phpgw::get_var('start_date','string'), 
"d/m-Y" );
+                                       $start_date_ts = 
date_helper::get_timestamp_from_date( phpgw::get_var('start_date','string'), 
$dateformat );
                                        $this->set_start_date($start_date_ts);
                                }else
                                        $this->set_start_date(0);
                                                                
                                if( phpgw::get_var('end_date','string') != '')
                                {
-                                       $end_date_ts = 
date_helper::get_timestamp_from_date( phpgw::get_var('end_date','string'), 
"d/m-Y" );
+                                       $end_date_ts = 
date_helper::get_timestamp_from_date( phpgw::get_var('end_date','string'), 
$dateformat );
                                        $this->set_end_date( $end_date_ts );
                                }else
                                {




reply via email to

[Prev in Thread] Current Thread [Next in Thread]