Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding fix to ticket 157 setting the query date to use the timezone o… #158

Closed
wants to merge 1 commit into from
Closed

adding fix to ticket 157 setting the query date to use the timezone o… #158

wants to merge 1 commit into from

Conversation

juankk
Copy link

@juankk juankk commented Mar 10, 2020

…f the site

@tomjn
Copy link
Contributor

tomjn commented Mar 10, 2020

Should it not use UTC timestamps for all data saved and queried? WP stores all time and date values as UTC timestamps, then converts into localised time when displayed. The server too should be using UTC time.

Needing to use localised time to query implies that either somebody incorrectly used localised times somewhere and stripped out the timezones so that 2pm Sydney time became 2pm UTC, or that the timestamps are being stored incorrectly by the plugin. by my understanding this PR will break things for some or all users

@t-wright
Copy link

Should it not use UTC timestamps for all data saved and queried?

It currently queries post_date which is a localised timestamp. An alternative could be to query post_date_gmt but this column is not indexed.

@technosailor
Copy link

@tomjn I work with @juankk and trying to follow up on this to find a resolution. I understand your concern and @t-wright's thought on using post_date_gmt is sort of a good idea except UTC !== GMT for things like DST.

Regardless, perhaps a way forward here, and I can submit a PR with a different approach, is to use filters here. And also maybe hardened libraries for this.

Idea:

$start_date = apply_filters( 'msm_sitemap/start_date', function ( $start_date ) {
	$date = new \DateTime( $time, new \DateTimeZone( 'Australia/Sydney' ) );
	
	return $date->format( 'Y-m-d H:i:s' );
} );

$end_date = apply_filters( 'msm_sitemap/end_date', function ( $end_date ) {
	$date = new \DateTime( $time, new \DateTimeZone( 'Australia/Sydney' ) );
	
	return $date->format( 'Y-m-d H:i:s' );
} );

Thoughts?

@juankk juankk closed this by deleting the head repository May 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants