WordPress.org

Make WordPress Core

Opened 8 years ago

Last modified 11 months ago

#10660 assigned feature request

Time zone suggester based on nascent WordPress.org API call

Reported by: sambauers Owned by: rmccue
Milestone: Future Release Priority: normal
Severity: normal Version: 2.8.4
Component: Date/Time Keywords: needs-patch dev-feedback
Focuses: javascript Cc:

Description

The attached patch uses a new API call to http://api.wordpress.org/core/ip-to-zoneinfo/1.0/ to retrieve a suggested time zone based on client (not server) IP address.

A button is added next to the existing dropdown list of time zones providing the option to "Suggest a time zone". This calls the API using an AJAX/JSONP request which then auto-selects a time zone for the user from the dropdown.

Visual feedback is via a spinner when fetching and then a text response.

Additionally the Date and Time settings have been split out to a new settings page.

Related ticket: #10324

Attachments (3)

datetime-and-timezone-suggest.patch (22.2 KB) - added by sambauers 8 years ago.
10660.diff (4.1 KB) - added by rmccue 7 years ago.
Updated (and simpler) patch
10660-refresh.diff (3.5 KB) - added by rmccue 5 years ago.
Refresh patch

Download all attachments as: .zip

Change History (28)

#1 @sambauers
8 years ago

An attribution for use of GeoNames will need to be included somewhere in the interface or on the WordPress.org site/docs for us to be able to use this.

#2 @Otto42
8 years ago

  • Cc otto@… added

#3 @cnorris23
8 years ago

  • Cc cnorris23@… added

#4 @nacin
8 years ago

  • Milestone changed from Unassigned to 3.1
  • Type changed from task (blessed) to feature request

Moving to 3.1. Not sure we need to spawn another options panel for this though.

#5 @nacin
7 years ago

  • Milestone changed from Awaiting Triage to Future Release

@rmccue
7 years ago

Updated (and simpler) patch

#6 @rmccue
7 years ago

  • Keywords gci added
  • Owner set to rmccue
  • Status changed from new to assigned

This updated patch does the same as Sam's, but simpler, and also asks the user before using the supplied timezone as the value.

#7 @danielbachhuber
6 years ago

  • Cc d@… added

#8 follow-up: @azaozz
6 years ago

I see this as "pure" JS based solution. The browser "knows" the right timezone and the UTC offset. The user's IP might not be in the same timezone (proxy?).

#9 @Otto42
5 years ago

We have a name-to-zoneinfo API call too:

http://api.wordpress.org/core/name-to-zoneinfo/1.0/?callback=abcd&s=memphis

Could be good for auto-suggest based on search string.

@rmccue
5 years ago

Refresh patch

#10 @Otto42
5 years ago

#10324 was marked as a duplicate.

#11 @helenyhou
5 years ago

#9759 was marked as a duplicate.

#12 @helenyhou
5 years ago

  • Component changed from Administration to Date/Time

#13 @travisnorthcutt
5 years ago

  • Cc travis@… added

http://pellepim.bitbucket.org/jstz/ might be a candidate for use... grabs a timezone as opposed to a UTC offset, and is MIT licensed so inclusion in core should be possible.

#15 @travisnorthcutt
5 years ago

Not my area of expertise, but if it works, then great.

I'm not one to look a gift horse in the mouth ;)

#16 @ericlewis
4 years ago

There is a jQuery Timezone picker that could be considered to solve this problem as well. Finding your place on a world map is an instantly understood UI, and adds a bit of character.

#18 in reply to: ↑ 17 ; follow-up: @rmccue
4 years ago

Replying to ericlewis:

Another option: timezone selection with d3

Cool, but not accurate (it's missing the Sydney timezone, at least). The jQuery library is a better interface IMO, and looks more accurate.

#19 in reply to: ↑ 18 @ericlewis
4 years ago

Replying to rmccue

Cool, but not accurate (it's missing the Sydney timezone, at least). The jQuery library is a better interface IMO, and looks more accurate.

The d3 example is crude, but there would be benefits with D3. There's Low overhead for complete control over the map.

Since D3 uses SVG, we could use the new admin color schemes to inform the map's colors.

Finding the right timezone tiling shouldn't be too hard either since it uses GeoJSON.

Last edited 4 years ago by ericlewis (previous) (diff)

#20 @sambauers
4 years ago

The jQuery one is much nicer, and the payload overhead is about the same as the D3 one. The D3 JS is about @40KB Gzipped. The extra JS on the jQuery one is @4KB + the map image is about @35KB.

Supporting a jQuery plugin is less development overhead than adding a new library.

Best zombie ticket ever BTW!

#21 @chriscct7
2 years ago

  • Keywords needs-patch dev-feedback added; has-patch gci removed

#22 in reply to: ↑ 8 @ericlewis
2 years ago

Replying to azaozz:

I see this as "pure" JS based solution. The browser "knows" the right timezone and the UTC offset. The user's IP might not be in the same timezone (proxy?).

Coming back, this seems the best solution, please excuse my earnest vision of using D3 here.

#23 @rmccue
18 months ago

I implemented timezone detection via the browser for a project I was working on. Unfortunately, the browser doesn't report the Olsen timezone via JS, only the timezone offset. There's a nice little library that applies heuristics based on the offset and DST information, but this isn't native to the browser.

One potentially easier solution would be to use getTimezoneOffset() to provide filtered suggestions for the picker, and expose these to the user. This would require outputting the timezone offset in wp_timezone_choice(), which would also allow us to show the current time live as you change the timezone.

#24 @Otto42
18 months ago

Sad to say that an 11+ K script (after minification) is currently the best option for browser side detection. Still seems to have quite a few issues though, several in their list involve it giving different answers on different browsers.

https://bitbucket.org/pellepim/jstimezonedetect

It's worth noting that the current WP code basically outputs all the timezones PHP knows about, including historical ones. It might be worth trimming that down to only modern timezones, in the same way that the library above does. Looks like they're only including 72 current timezones, approximately.

#25 @dd32
11 months ago

  • Focuses javascript added

FWIW see this comment on #28988 by myself:

It looks like we'll be able to use Intl.DateTimeFormat().resolvedOptions().timeZone here now.

It's supported by recent Chrome & Safari, Firefox 52 will support it (Currently in the Developer channel), however IE is likely not implementing it. Progressive enhancement to support it when possible seems like a good option to me.

Note: See TracTickets for help on using tickets.