[wp-hackers] Re: Sqlite

Martin Geisler mgeisler at mgeisler.net
Thu Jun 23 11:59:19 GMT 2005


David House <dmhouse at gmail.com> writes:

> On 6/23/05, Mark Jaquith <mark.wordpress at txfx.net> wrote:
>>  Current method:  store GMT time, and local time
>>  Your method: store GMT time, and offset to local time
>>  
>>  Two variables either way... I don't really see an upside.
>
> I think he was talking about using a timestamp (seconds since the unix
> epoch) instead of mySQL's DATETIME.

Yes, thanks! :-)

I would then have all the WordPress code that deals with dates use the
integer timestamp instead of converting back and forth between strings
and integers multiple times --- having just a single rule ("all
timestamps are integers, measuring the number of seconds since Jan 1st
1970 GMT") makes a lot of things easier.

See the get_lastpostdate() function in wp-includes/functions.php for
example. It uses one of three similar queries to figure out which post
has the greatest timestamp and to return it in GMT, server, or blog
time. I think that's too complicated --- first of all a single query
should be enough with my imaginary table schema:

  SELECT post_date, timezone_offset
  FROM $wpdb->posts
  WHERE post_date <= NOW() AND post_status = 'publish'
  ORDER BY post_date DESC
  LIMIT 1

Then depending on the wanted return value you'll either return
post_date (for 'gmt' output) or post_date + timezone_offset for 'blog'
output. I don't know about the 'server' output --- hint, hint: this
function could use a comment or two explaining the possible arguments
and the return types!

Of course you wouldn't even want to be able to return anything other
than GMT time with a WP that deals with GMT throughout its entire
codebase.  So that would make the last paragraph unnecessary.

-- 
Martin Geisler                                     GnuPG Key: 0x7E45DD38

PHP EXIF Library      |  PHP Weather             |  PHP Shell
http://pel.sf.net/    |  http://phpweather.net/  |  http://mgeisler.net/
Read/write EXIF data  |  Show current weather    |  A shell in a browser
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 188 bytes
Desc: not available
Url : http://comox.textdrive.com/pipermail/wp-hackers/attachments/20050623/5b42f53a/attachment.bin


More information about the wp-hackers mailing list