Changeset 46083
- Timestamp:
- 05/15/08 20:01:06 (2 months ago)
- Files:
-
- uk-time/trunk/readme.txt (modified) (3 diffs)
- uk-time/trunk/uktime.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
uk-time/trunk/readme.txt
r37866 r46083 1 1 === Plugin Name === 2 Contributors: Kalessin3 Tags: time zone, british summer time, utc, daylight saving time2 Contributors: Alex Coles 3 Tags: british summer time, bst, daylight saving time, gmt, greenwich mean time, time zone, utc 4 4 Requires at least: 2.0 5 Tested up to: 2.5 6 Stable tag: 1. 05 Tested up to: 2.5.1 6 Stable tag: 1.2 7 7 8 8 Plugin to automatically adjust for British Summer Time. … … 10 10 == Description == 11 11 12 The UK Time plugin reads the modification time of each post being displayed and adds an hour if it falls inside British Summer Time.12 The UK Time plugin reads the modification time of each post and comment being displayed and adds an hour if it falls inside British Summer Time. 13 13 14 * Works with existing posts15 14 * No need to adjust the UTC offset ever again 16 * Nothing is permanently changed 15 * Works with existing posts and comments, even if you used to adjust the UTC offset 16 * No times or dates are permanently changed 17 17 18 18 Requires the web server's time zone to be UTC. … … 22 22 1. Unzip and upload the `uktime.php` file to the `/wp-content/plugins` directory 23 23 1. Activate the plugin from the `Plugins` menu in WordPress 24 1. Ensure your theme s use`<?php the_time() ?>` to display the time and `<?php the_date()` to display the date.*24 1. Ensure your theme uses `<?php the_time() ?>` to display the time and `<?php the_date()` to display the date.* 25 25 26 * Hint: The default theme supplied with WordPress uses `<?php the_time('F jS, Y') ?>`. This will be left unmodified by the UK Time plugin. To control the format of the date and time, go to the `Settings` menu in WordPress.26 * Note: The default theme supplied with WordPress uses its own parameters to control the format of the date and time: `<?php the_time('F jS, Y') ?>`. The UK Time plugin will not modify any times and dates which do not use the global date and time format. To adjust the global date and time format, go to the `Settings` menu in WordPress. uk-time/trunk/uktime.php
r37866 r46083 5 5 Description: Checks dates and times and adjusts for British Summer Time if applicable. Requires the use of the defaults <code>the_time()</code> and <code>the_date()</code> in the active theme. No times are permanently changed. 6 6 Author: Alex Coles 7 Version: 1. 07 Version: 1.2 8 8 Author URI: http://www.alexcoles.com 9 9 */ 10 10 11 function adjust_for_BST($ supplied_time)11 function adjust_for_BST($timestamp) 12 12 { 13 // Check if supplied arg is a date or a time (so this function can be used for both)14 if ($supplied_time==get_post_time(get_settings('time_format')))15 {16 $filter='time';17 }18 elseif ($supplied_time==get_post_time(get_settings('date_format')))19 {20 $filter='date';21 }22 // Date or time format is set by theme -- do nothing.23 else24 {25 return $supplied_time;26 }27 // retrieve post time in Unix timestamp format28 $timestamp=get_post_time('U',true);29 13 // find the year of the supplied timestamp 30 14 $supplied_year=(date('Y',$timestamp)); … … 40 24 // Add an hour to the time, if the date falls within BST. 41 25 if (($timestamp>=$BST_start) && ($timestamp<$BST_end)) { $timestamp=$timestamp+3600; } 26 return $timestamp; 27 } 28 29 function adjust_post_time($supplied_time) 30 { 31 // Check if supplied arg is a date or a time (so this function can be used for both) 32 if ( $supplied_time==get_post_time(get_settings('time_format')) ) 33 { 34 $filter='time'; 35 } 36 elseif ( $supplied_time==get_post_time(get_settings('date_format')) ) 37 { 38 $filter='date'; 39 } 40 // Date or time format is set by theme -- do nothing. 41 else 42 { 43 return $supplied_time; 44 } 45 // retrieve post time in Unix timestamp format 46 $timestamp=adjust_for_BST(get_post_time('U',true)); 42 47 if ($filter=='time') 43 48 { … … 50 55 } 51 56 52 add_filter('the_time', 'adjust_for_BST'); 53 add_filter('the_date', 'adjust_for_BST'); 57 function adjust_comment_time($supplied_time) 58 { 59 global $comment; 60 // Check if supplied arg is a date or a time (so this function can be used for both) 61 if ( $supplied_time==mysql2date(get_option('time_format'), $comment->comment_date_gmt) ) 62 { 63 $filter='time'; 64 } 65 elseif ( $supplied_time==mysql2date(get_option('date_format'), $comment->comment_date_gmt) ) 66 { 67 $filter='date'; 68 } 69 // Date or time format is set by theme -- do nothing. 70 else 71 { 72 return $supplied_time; 73 } 74 // retrieve post time in Unix timestamp format 75 $timestamp=adjust_for_BST(mysql2date('U', $comment->comment_date_gmt)); 76 if ($filter=='time') 77 { 78 return date(get_settings('time_format'),$timestamp); 79 } 80 else 81 { 82 return date(get_settings('date_format'),$timestamp); 83 } 84 } 85 86 add_filter('the_time', 'adjust_post_time'); 87 add_filter('the_date', 'adjust_post_time'); 88 add_filter('get_comment_time', 'adjust_comment_time'); 89 add_filter('get_comment_date', 'adjust_comment_time'); 54 90 ?>
