Index: trunk/extensions/SemanticForms/includes/SF_FormInputs.php |
— | — | @@ -746,7 +746,17 @@ |
747 | 747 | $day = $date['day']; |
748 | 748 | } else { |
749 | 749 | // handle 'default=now' |
750 | | - if ( $date == 'now' ) $date = date( 'Y/m/d' ); |
| 750 | + if ( $date == 'now' ) { |
| 751 | + global $wgLocaltimezone; |
| 752 | + if ( isset( $wgLocaltimezone ) ) { |
| 753 | + $serverTimezone = date_default_timezone_get(); |
| 754 | + date_default_timezone_set( $wgLocaltimezone ); |
| 755 | + } |
| 756 | + $date = date( 'Y/m/d' ); |
| 757 | + if ( isset( $wgLocaltimezone ) ) { |
| 758 | + date_default_timezone_set( $serverTimezone ); |
| 759 | + } |
| 760 | + } |
751 | 761 | $actual_date = new SMWTimeValue( '_dat' ); |
752 | 762 | $actual_date->setUserValue( $date ); |
753 | 763 | $year = $actual_date->getYear(); |
— | — | @@ -805,8 +815,19 @@ |
806 | 816 | } else { |
807 | 817 | // TODO - this should change to use SMW's own |
808 | 818 | // date-handling class, just like |
809 | | - // dateEntryHTML() does |
810 | | - $actual_date = strtotime( $datetime ); |
| 819 | + // dateEntryHTML() does. |
| 820 | + |
| 821 | + // Handle 'default=now'. |
| 822 | + if ( $datetime == 'now' ) { |
| 823 | + global $wgLocaltimezone; |
| 824 | + if ( isset( $wgLocaltimezone ) ) { |
| 825 | + $serverTimezone = date_default_timezone_get(); |
| 826 | + date_default_timezone_set( $wgLocaltimezone ); |
| 827 | + } |
| 828 | + $actual_date = time(); |
| 829 | + } else { |
| 830 | + $actual_date = strtotime( $datetime ); |
| 831 | + } |
811 | 832 | if ( $sfg24HourTime ) { |
812 | 833 | $hour = date( "G", $actual_date ); |
813 | 834 | } else { |
— | — | @@ -818,6 +839,12 @@ |
819 | 840 | $ampm24h = date( "A", $actual_date ); |
820 | 841 | } |
821 | 842 | $timezone = date( "T", $actual_date ); |
| 843 | + // Restore back to the server's timezone. |
| 844 | + if ( $datetime == 'now' ) { |
| 845 | + if ( isset( $wgLocaltimezone ) ) { |
| 846 | + date_default_timezone_set( $serverTimezone ); |
| 847 | + } |
| 848 | + } |
822 | 849 | } |
823 | 850 | } else { |
824 | 851 | $cur_date = getdate(); |
— | — | @@ -850,7 +877,7 @@ |
851 | 878 | |
852 | 879 | if ( $include_timezone ) { |
853 | 880 | $sfgTabIndex++; |
854 | | - $text .= ' <input tabindex="' . $sfgTabIndex . '" name="' . $input_name . '[timezone]" type="text" value="' . $timezone . '" size="2"/ ' . $disabled_text . '>' . "\n"; |
| 881 | + $text .= ' <input tabindex="' . $sfgTabIndex . '" name="' . $input_name . '[timezone]" type="text" value="' . $timezone . '" size="3"/ ' . $disabled_text . '>' . "\n"; |
855 | 882 | } |
856 | 883 | |
857 | 884 | return $text; |
Index: trunk/extensions/SemanticForms/includes/SF_FormPrinter.php |
— | — | @@ -949,9 +949,12 @@ |
950 | 950 | if ( $input_type == 'date' || $input_type == 'datetime' || |
951 | 951 | $input_type == 'datetime with timezone' || $input_type == 'year' || |
952 | 952 | ( $input_type == '' && $form_field->template_field->propertyIsOfType( '_dat' ) ) ) { |
953 | | - // get current time, for the time zone specified in the wiki |
| 953 | + // Get current time, for the time zone specified in the wiki. |
954 | 954 | global $wgLocaltimezone; |
955 | | - putenv( 'TZ=' . $wgLocaltimezone ); |
| 955 | + if ( isset( $wgLocaltimezone ) ) { |
| 956 | + $serverTimezone = date_default_timezone_get(); |
| 957 | + date_default_timezone_set( $wgLocaltimezone ); |
| 958 | + } |
956 | 959 | $cur_time = time(); |
957 | 960 | $year = date( "Y", $cur_time ); |
958 | 961 | $month = date( "n", $cur_time ); |
— | — | @@ -964,6 +967,9 @@ |
965 | 968 | } else { |
966 | 969 | $cur_value_in_template = "$year/$month/$day"; |
967 | 970 | } |
| 971 | + if ( isset( $wgLocaltimezone ) ) { |
| 972 | + date_default_timezone_set( $serverTimezone ); |
| 973 | + } |
968 | 974 | if ( $input_type == 'datetime' || $input_type == 'datetime with timezone' ) { |
969 | 975 | if ( $sfg24HourTime ) { |
970 | 976 | $hour = str_pad( intval( substr( date( "G", $cur_time ), 0, 2 ) ), 2, '0', STR_PAD_LEFT ); |