TimeZone Download 2.0

This component/theme works with latest OSSN version.
5.0
Indonesian Arsalan Shah 3 years ago

Allow users to setup time zone for their profile. This timezone can be utilized later by components.

V2.0

  • Updated timezones list to more readable format!

enter image description here

Comments
us Pariter Retirap Replied 6 months ago

Reported on WhatsApp
Follow up Bug Report
If a user does not select a timezone(leaves drop down in default loaded state) and makes an error while filling out the required fields of the create account form (i.e. incorrect username), the Timezone component stops the form from reporting out to the user that they have made an error. If the user then updates the timezone component to a time zone, the form will report out properly that they have created an error.

us J Miller Replied 11 months ago

@jambu, where is the full code? I'd love to use it, if it works. Thanks!

German Michael Z├╝lsdorff Replied 2 years ago

Thanks for your contribution, Jambu.
I'd appreciate a link to your repository, though.
Because coding "something similar" is a bit too vague for most of us, I guess. 😵

us Jambu Atchison Replied 2 years ago

I made these changes to the source files so that the timezone is automatically set by the user's local timezone. I checked out the repo from github to branch and commit these, but it didn't have any of these files... Well this is not letting me put all the changes I made. But something like this:

In both:
components/TimeZone/plugins/default/js/timezone/account_settings.php
components/TimeZone/plugins/default/js/timezone/create_account.php

I did something similar to this:

const local_timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
var select = $('.timezone-dropdown');
var option = select.find("option:contains("+ local_timezone +")");
var optionTop = option.offset().top
var selectTop = select.offset().top;
select.scrollTop(select.scrollTop() + (optionTop - selectTop));
option.prop('selected', true);
us Mary Greg Replied 2 years ago

It is not available in version 5.0 can you explain reason?

gb Shaf Brady Replied 2 years ago

Thanks for your work, using nearly all the components haha.

us Bansh33 - Replied 2 years ago

(just to be clear, this was about time ZONES, not the exact city a user may be located in. Z-Man's response is correct that it's not easy to determine that. If you prefer the UTC offset of your time ZONE rather than the city usually associated with that timezone as my example displays, that's easy enough to find also, just read the stackoverflow post I linked)

us Bansh33 - Replied 2 years ago

working jsfiddle showing a user's DEFAULT timezone as set in their browser in about 2 lines of code: jsfiddle.net/k12qL5xz

us Bansh33 - Replied 2 years ago

(in reference to my last post)

since Goodwin specifically asked why users should have to go through the stress of locating their correct time zone, you could do something like the following:

  • on user login, get the user's current timezone using the js code in my previous comment.
  • save timezone to database as user's mostrecenttimezone
  • display in profile

easy peasy. alternatively you can give the user option to update their current timezone in their profile settings. I really don't see what's so difficult about this.

us Bansh33 - Replied 2 years ago

Z-Man, it's perfectly possible to do with javascript (and not very difficult), even though not with PHP: https://stackoverflow.com/questions/6939685/get-client-time-zone-from-browser

javascript is used all over the place in OSSN, while it may be primarily PHP, it's certainly not exclusively written using PHP. I really don't see what's so difficult or prohibitive about:

const tz = Intl.DateTimeFormat().resolvedOptions().timeZone;
console.log(tz);

obviously its not going to be possible with a server side lang like php because timezone is set on the client side.

Hope that helps, Estee and Goodwin.

Component

Developer: Arsalan
License ossnv3
Type: User admin
Requires Ossn Version : 5.0
Latest Version: 2.0
Last Updated 1 year ago
Repository Url View Repository

Versions