Changeset 21996 for trunk/wp-includes/formatting.php
- Timestamp:
- 09/25/2012 05:26:19 AM (13 years ago)
- File:
-
- 1 edited
-
trunk/wp-includes/formatting.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/formatting.php
r21993 r21996 1899 1899 $datetime->setTimezone( new DateTimeZone('UTC') ); 1900 1900 $offset = $datetime->getOffset(); 1901 $datetime->modify( '+' . $offset / 3600. ' hours');1901 $datetime->modify( '+' . $offset / HOUR_IN_SECONDS . ' hours'); 1902 1902 $string_gmt = gmdate($format, $datetime->format('U')); 1903 1903 … … 1905 1905 } else { 1906 1906 $string_time = gmmktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]); 1907 $string_gmt = gmdate($format, $string_time - get_option('gmt_offset') * 3600);1907 $string_gmt = gmdate($format, $string_time - get_option('gmt_offset') * HOUR_IN_SECONDS); 1908 1908 } 1909 1909 return $string_gmt; … … 1925 1925 preg_match('#([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $string, $matches); 1926 1926 $string_time = gmmktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]); 1927 $string_localtime = gmdate($format, $string_time + get_option('gmt_offset') *3600);1927 $string_localtime = gmdate($format, $string_time + get_option('gmt_offset') * HOUR_IN_SECONDS); 1928 1928 return $string_localtime; 1929 1929 } … … 1945 1945 $hours = intval(substr($timezone, 1, 2)); 1946 1946 $minutes = intval(substr($timezone, 3, 4)) / 60; 1947 $offset = $sign * 3600* ($hours + $minutes);1947 $offset = $sign * HOUR_IN_SECONDS * ($hours + $minutes); 1948 1948 } 1949 1949 return $offset; … … 1969 1969 $offset = iso8601_timezone_to_offset($date_bits[7]); 1970 1970 } else { // we don't have a timezone, so we assume user local timezone (not server's!) 1971 $offset = 3600* get_option('gmt_offset');1971 $offset = HOUR_IN_SECONDS * get_option('gmt_offset'); 1972 1972 } 1973 1973 … … 2094 2094 */ 2095 2095 function human_time_diff( $from, $to = '' ) { 2096 if ( empty( $to) )2096 if ( empty( $to ) ) 2097 2097 $to = time(); 2098 $diff = (int) abs( $to - $from);2099 if ( $diff <= 3600) {2100 $mins = round( $diff / 60);2101 if ( $mins <= 1) {2098 $diff = (int) abs( $to - $from ); 2099 if ( $diff <= HOUR_IN_SECONDS ) { 2100 $mins = round( $diff / MINUTE_IN_SECONDS ); 2101 if ( $mins <= 1 ) { 2102 2102 $mins = 1; 2103 2103 } 2104 2104 /* translators: min=minute */ 2105 $since = sprintf( _n('%s min', '%s mins', $mins), $mins);2106 } else if (($diff <= 86400) && ($diff > 3600)) {2107 $hours = round( $diff / 3600);2108 if ( $hours <= 1) {2105 $since = sprintf( _n( '%s min', '%s mins', $mins ), $mins ); 2106 } elseif ( ( $diff <= DAY_IN_SECONDS ) && ( $diff > HOUR_IN_SECONDS ) ) { 2107 $hours = round( $diff / HOUR_IN_SECONDS ); 2108 if ( $hours <= 1 ) { 2109 2109 $hours = 1; 2110 2110 } 2111 $since = sprintf( _n('%s hour', '%s hours', $hours), $hours);2112 } elseif ( $diff >= 86400) {2113 $days = round( $diff / 86400);2114 if ( $days <= 1) {2111 $since = sprintf( _n( '%s hour', '%s hours', $hours ), $hours ); 2112 } elseif ( $diff >= DAY_IN_SECONDS ) { 2113 $days = round( $diff / DAY_IN_SECONDS ); 2114 if ( $days <= 1 ) { 2115 2115 $days = 1; 2116 2116 } 2117 $since = sprintf( _n('%s day', '%s days', $days), $days);2117 $since = sprintf( _n( '%s day', '%s days', $days ), $days ); 2118 2118 } 2119 2119 return $since;
Note: See TracChangeset
for help on using the changeset viewer.