Search the database
Search forum topics
Search members
Search for trades
diablo2.io is supported by ads
diablo2.io is supported by ads
22 replies   1525 views
2

Description

The community here shares a lot of information with each other about upcoming Dclone walks, mainly in the two threads post2398234.html and post2546635.html. For public walks there's usually a set time for the walk that is announced well in advance, like for example how many Korean Dclone walks take place at 12:00 or 13:00 UTC, on the hour. There's sometimes confusion around what time is actually meant for a walk, seeing as how there are people from all over the world on this forum and not everyone is meticulous about specifying the time zone for a walk time. Also, even if time zones are specified, not everyone is familiar with all the time zone abbreviations and how they relate to each other (and this can get especially confusing during the weeks when the world shifts to or from Daylight Savings Time, as this happens on different dates in different time zones, but this is really not the point).

On Discord there's a neat little feature where you can include special timestamp tags in posts, which essentially makes a post display different time values depending on who is viewing it. The format of a timestamp tag is essentially as follows:

<t:timestamp:X>

where timestamp is a so-called Unix Epoch value (number of seconds since 1970-01-01 00:00:00 UTC), and X is a code which determines how the date and/or time is output, for example "F" for a complete date and time including day of week, or "R" for a relative value (how many hours or minutes remains until the specified time, or how many hours/minutes have passed since the specified time). There are more variants than these two.

I thought it would be a neat feature if there was a similar timestamp tag for posts on this forum, perhaps with a date & time selector. It need not be in the exact same format that Discord uses, of course. I understand that this may be an incredibly niche use case and may not be worth the time investment to implement, but it would certainly make sharing information about upcoming Dclone walks easier.
Description by ShadowHeart
5

Can be used to make Runewords:

7
User avatar

ShadowHeart 2639Moderator

Europe PC
The community here shares a lot of information with each other about upcoming Dclone walks, mainly in the two threads post2398234.html and post2546635.html. For public walks there's usually a set time for the walk that is announced well in advance, like for example how many Korean Dclone walks take place at 12:00 or 13:00 UTC, on the hour. There's sometimes confusion around what time is actually meant for a walk, seeing as how there are people from all over the world on this forum and not everyone is meticulous about specifying the time zone for a walk time. Also, even if time zones are specified, not everyone is familiar with all the time zone abbreviations and how they relate to each other (and this can get especially confusing during the weeks when the world shifts to or from Daylight Savings Time, as this happens on different dates in different time zones, but this is really not the point).

On Discord there's a neat little feature where you can include special timestamp tags in posts, which essentially makes a post display different time values depending on who is viewing it. The format of a timestamp tag is essentially as follows:

<t:timestamp:X>

where timestamp is a so-called Unix Epoch value (number of seconds since 1970-01-01 00:00:00 UTC), and X is a code which determines how the date and/or time is output, for example "F" for a complete date and time including day of week, or "R" for a relative value (how many hours or minutes remains until the specified time, or how many hours/minutes have passed since the specified time). There are more variants than these two.

I thought it would be a neat feature if there was a similar timestamp tag for posts on this forum, perhaps with a date & time selector. It need not be in the exact same format that Discord uses, of course. I understand that this may be an incredibly niche use case and may not be worth the time investment to implement, but it would certainly make sharing information about upcoming Dclone walks easier.
Request fulfilledby Teebling1 year agoGo to post
Added dynamic timestamps in 1.41.

Still aware of use case with just hours +- offset, will consider for next patch.

I'm in CET (Central European Time), so that's UTC+1 normally and UTC+2 during DST.
My profile says Ladder, but I play both Ladder and Non-Ladder.
7
User avatar

Schnorki 3813Moderator

PC
Lovely idea. Seconded. Not just for DClones actually (though other uses will indeed be niche).

Folks like you or I would more likely than not use it reliably in relayed announcements if available.

Though the same folks not specifying timezones at all now more likely than not won't go through even more hassle to utilize this, sadly.
7
OP
User avatar

ShadowHeart 2639Moderator

Europe PC
Schnorki wrote: 2 years ago
Lovely idea. Seconded. Not just for DClones actually (though other uses will indeed be niche).

Folks like you or I would more likely than not use it reliably in relayed announcements if available.

Though the same folks not specifying timezones at all now more likely than not won't go through even more hassle to utilize this, sadly.
It may take a while, but I think (hope?) most people would start using it eventually after they see "everyone else" doing it. Maybe I'm too optimistic? But even if someone does not, for whatever reason, the rest of us who would use the feature could make sure to always make a follow-up post with proper tag(s). It's some extra effort, sure, but I think we could manage :-)

I'm in CET (Central European Time), so that's UTC+1 normally and UTC+2 during DST.
My profile says Ladder, but I play both Ladder and Non-Ladder.
7
User avatar

Schnorki 3813Moderator

PC
Agreed
7
I could use it for my signature

On workdays I am generally available for trade from 19:00 CET to 23:00 CET. Weekends variable.
7
I like the idea.
7
User avatar

Teebling 6875Admin

Europe PC
Before I look into this, could someone in a US or European (any non-UTC zone) timezone please do the following:

Go to 'Account Prefs' then 'Global Defaults' and check if your timezone has been set automatically by the board (the 'suggested' time is the one to look at).

If I can confirm that people's timezones are being set correctly by the board, there is potentially a way I can do this with Javascript (after page load) or PHP (before page load, optimal for performance).

Would be an on-load event - if the BBcode is detected in post content, then the viewing user's timezone is queried from database, compared with the UTC timezone to determine difference in hours, UTC timestamp provided by the poster wrapped in BBCode is then added to or subtracted from to provide a 'local' time for the viewer, and potentially a 'local relative' time (X days Y hours from now), all parsed and then displayed in place of the original BBCode string in the post.

Again, as Schnorki has pointed out, this requires the poster to always use the UTC time of the walk (if they get this wrong the whole exercise is pointless and potentially will cause more disruption), and to be aware that the BBcode exists to do this. Lots rests on the poster making the correct entry for this to be effective, like most features on the site.

7
User avatar

Schnorki 3813Moderator

PC
Doesn't seem to specifically list a "suggested time" in the global defaults.

It has the correct (non-UTC) timezone for me but I can't recall if I ever changed that manually or if that was the default.


Side note:
Any chance of hooking into existing functionality to ease the work this would mean? E.g. just noticed (or remembered rather) that hovering over the "3 minutes ago" or whenever in a post gives you the exact post time converted to your timezone already. Might be able to hook into/recycle that function for efficiency.

But yeah, this definitely boils down to correct usage. As with most things, as you correctly noted.
Though if you make the entry of the code form-based, you could hook into the same default and convert to UTC from whatever local time is entered. So long as it is labeled correctly (noting to enter in local time), those who read/pay attention would know to stick to their local time and those who don't read/do it wrong would coincidentally do it right as they're most likely to stick with their local time anyways. (He who doesn't go through the effort of understanding such a function likely also doesn't go through the effort of converting to UTC first)
7
OP
User avatar

ShadowHeart 2639Moderator

Europe PC
Teebling wrote: 2 years ago
Before I look into this, could someone in a US or European (any non-UTC zone) timezone please do the following:

Go to 'Account Prefs' then 'Global Defaults' and check if your timezone has been set automatically by the board (the 'suggested' time is the one to look at).

If I can confirm that people's timezones are being set correctly by the board, there is potentially a way I can do this with Javascript (after page load) or PHP (before page load, optimal for performance).

Would be an on-load event - if the BBcode is detected in post content, then the viewing user's timezone is queried from database, compared with the UTC timezone to determine difference in hours, UTC timestamp provided by the poster wrapped in BBCode is then added to or subtracted from to provide a 'local' time for the viewer, and potentially a 'local relative' time (X days Y hours from now), all parsed and then displayed in place of the original BBCode string in the post.

Again, as Schnorki has pointed out, this requires the poster to always use the UTC time of the walk (if they get this wrong the whole exercise is pointless and potentially will cause more disruption), and to be aware that the BBcode exists to do this. Lots rests on the poster making the correct entry for this to be effective, like most features on the site.
For me it lists the correct UTC offset (+02:00, I'm in EU and we're currently observing Daylight Savings Time, so instead of the standard +01:00 UTC offset we're at +02:00 until the end of October), but the dropdown suggests the wrong time zone. It suggest "Africa/Blantyre", which I suppose is the same as Central African Time, which does not observe DST, it has the same +02:00 offset all year. I suppose this does not really matter though - the most important part, I guess, is that it detects the correct offset, and it does so. I presume that if I check that page again after DST has ended for 2022 it should tell me that my offset is +01:00.

I fully understand that this boils down to correct usage, but I'm optimistic that the community here can work together to educate each other and solve any issues with incorrect usage :-)

I'm in CET (Central European Time), so that's UTC+1 normally and UTC+2 during DST.
My profile says Ladder, but I play both Ladder and Non-Ladder.
7
User avatar

Bisu 382

PC
If this gets implemented with JS after page load, then instead of querying the database for user settings (which could be mistaken due to user input, or the user might be travelling in a different time zone and the database doesn't know about that), I wonder if we could directly get the time info from the browser.

For example,

Code: Select all

-new Date().getTimezoneOffset()
will calculate GMT's offset from the browser's time zone in minutes (hence the minus sign);

Or,

Code: Select all

Intl.DateTimeFormat().resolvedOptions().timeZone
, which will provide the time zone name. This is less convenient as then there needs a
Conversion
to figure out the offset.

With the UTC timestamp provided by the poster wrapped in BBCode, and the user's actual time zone obtained, the rest will then be the same as Teeb mentioned. The actual time zone info could be stored in sessionStorage if needed for performance optimization.
7
Teebling wrote: 2 years ago
Before I look into this, could someone in a US or European (any non-UTC zone) timezone please do the following:

Go to 'Account Prefs' then 'Global Defaults' and check if your timezone has been set automatically by the board (the 'suggested' time is the one to look at).
I can confirm the site correctly set this automatically for me - I did not. The UTC offset in the 1st dropdown is correct, but the 2nd dropdown for Timezone is not (for me, this doen't matter, but unsure if it may for some regions).

Having a "my timezone is [utcoffset][/utcoffset]" for signatures might be cool, if it's not too much trouble.

Traders: Please don't PM me for trades without a trade posting or add me on BNet without a comment on a trade posting

Image
Trade zone: PC | Softcore, Non-Ladder | UTC-8
7
User avatar

Teebling 6875Admin

Europe PC
Okay so I've managed to pull the user's current time zone offset in a query.
Showing that the user is 5 hours behind UTC.
Showing that the user is 5 hours behind UTC.
phpBB is dumb here and stores the user's current timezone as a string - this string can be any of dozens of different region names associated with each band of time offset like 'Africa/Algiers' or 'Pacific/Easter' which aren't time zones they're just the names of places within timezones.

So I have to write conditionals to end up capturing every possible string associated with a timezone in order to produce the desired result from the backend. So for example here's the code required to get the -5 offset to be returned from backend:

Code: Select all

		// Feb 2023 / 1.41 - Get user's current offset from UTC and store as template conditional in frontend

		// Query the current user by ID and fetch user_timezone fields
		$sqlage = "SELECT user_timezone FROM phpbb_users WHERE user_id='" . $user->data['user_id'] . "'";

		// No cache here in case people are switching settings around
		$resultage = $db->sql_query($sqlage);

		// With row returned...
		while($rowo = $db->sql_fetchrow($resultage)) {

			// Store value as variable
			$user_tz_raw = $rowo['user_timezone'];

			// Conditionals to derive number and operator from database strings

			// UTC -5
			if ($user_tz_raw = 'Pacific/Easter' || 
				$user_tz_raw = 'America/Atikokan' || 
				$user_tz_raw = 'America/Bogota' || 
				$user_tz_raw = 'America/Cancun' || 
				$user_tz_raw = 'America/Cayman' || 
				$user_tz_raw = 'America/Detroit' || 
				$user_tz_raw = 'America/Eirunepe' || 
				$user_tz_raw = 'America/Grand Turk' || 
				$user_tz_raw = 'America/Guayaquil' || 
				$user_tz_raw = 'America/Havana' || 
				$user_tz_raw = 'America/Indiana/Indianapolis' || 
				$user_tz_raw = 'America/Indiana/Marengo' || 
				$user_tz_raw = 'America/Indiana/Petersburg' || 
				$user_tz_raw = 'America/Indiana/Vevay' || 
				$user_tz_raw = 'America/Indiana/Vincennes' || 
				$user_tz_raw = 'America/Indiana/Winamac' || 
				$user_tz_raw = 'America/Iqaluit' || 
				$user_tz_raw = 'America/Jamaica' || 
				$user_tz_raw = 'America/Kentucky/Louisville' || 
				$user_tz_raw = 'America/Kentucky/Monticello' || 
				$user_tz_raw = 'America/Lima' || 
				$user_tz_raw = 'America/Nassau' || 
				$user_tz_raw = 'America/New York' || 
				$user_tz_raw = 'America/Nipigon' || 
				$user_tz_raw = 'America/Panama' || 
				$user_tz_raw = 'America/Pangnirtung' || 
				$user_tz_raw = 'America/Port-au-Prince' || 
				$user_tz_raw = 'America/Rio Branco' || 
				$user_tz_raw = 'America/Thunder Bay' || 
				$user_tz_raw = 'America/Toronto'
			) {

				// Offset from UTC time
				$user_tz = '5';

				// Operator required to go from UTC time to Local time
				$user_tz_op = '-';

			}

			// Assign the value as a template variable so we can pass it to Javascript solution for determining local time

			$template->assign_block_vars('zulutimezone',array(
				'USER_TIMEZONE' => $user_tz,
				'USER_TIMEZONE_OPERATOR' => $user_tz_op
			));

	     }
Pretty horrific right? If I cache the result, people will complain that the local time they see isn't in sync with whatever they changed their timezone settings to, making this even more costly for performance as it can't really be cached. Note that the above was JUST to get everyone in the -5 timezone. I would have to do the same for each timezone expressed by phpBB which is all the way from -11 to +14.

I haven't even looked into what the JS solution would be for the frontend yet, but again it's not as simple as it seems. It would be simple to pass the offset number 5 and the operator - to either add/subtract from the UTC time and give the local time. This works fine if dates didn't exist :P It starts to get very complicated when the date must also be converted for the local time to make sense:

For example if someone puts (and we're using DDMMYYYY here) 10/04/2023 0200 as the entry for UTC date/time of the dclone walk, we can't just subtract 5 from the time there, because it would show 10/04/2023 2100 as the local time, which is incorrect, the day needs to also turn to 09/04/2023.

This is all assuming that the people using the BBcode understand the exact format that the dates and times need to be entered, and assuming that I can find a javascript solution that is smart enough to also account for dates when it is adding or subtracting the offset.

So like, I'm not really sure I want to go much further with this guys, sorry. I've looked into it and it seems like a bit of a rabbithole to try and render dynamic date/times for those contributing dclone walks schedules with a custom BBcode. I'd recommend maybe using classic websites like https://www.timeanddate.com where you can enter UTC time there, and then share a link to that page, and from there users can select their local time.

What I might be able to do with this however is to at least allow a BBcode that says 'I am 5 hours behind UTC' etc. which could be displayed in signatures, or as a profile field or something to help with trading stuff. But tbh there's more important stuff for me to look at right now.

Anyways, got to get on with other stuff, thought I'd post as an update on this.

7
User avatar

Schnorki 3813Moderator

PC
That...sounds painfully dumb. Ouch.

There has to be some built-in way to go from string to time/offset or just bypass the string entirely. I mean..who came up with that? And to make it worse, what happens during daylight savings? Seeing how the location wouldn't change, neither would a locale string so you can't exactly just go "this place is always -5" but you'd have to catch what would basically amount to every time change world-wide per location and build that into your catch. Good lord..
Makes sense to not pursue that.

Since the main reason for the request was walk schedules though, let me just shamelessly plug feedback/suggestion-upcoming-walks-t1188212.html here as an alternative since that could be built in a simpler way with select default-conversions shown (or linked to), avoiding all of that. :)
7
User avatar

Teebling 6875Admin

Europe PC
Well I have no idea how daylight savings are going to factor into that tbh, but I got one step closer now with the JS solution working in the frontend (can't stop myself rn lol):

Edit: phpBB is capable of handling DST automatically apparently... I'm investigating now.

Code: Select all

<script>
  
  // Let's try and convert a UTC date/time string (expressed in ISO 8601 standard format) into a Local date/time string, by providing it with the offset and operator:

  // This is the JS function that does the conversion, we'll call it in a moment...
  function convertToLocalTime(utcDateTime, offset) {
    let date = new Date(utcDateTime);
    date.setHours(date.getHours() + offset);
    return date.toLocaleString();
  }

  $(document).ready(function() {

    // This will eventually point to (each) instance of BBcode it detects through a class selector
    // The date and time of the walk will have to be expressed in ISO 8601 standard format like this example:
    let utcDateTime = "2023-04-10T02:00:00";

    // This grabs the current viewing user's offset from UTC (the offset number and the offset operator)
    let user_tz_operator = $('.z-user-tz-operator').text();
    let user_tz = $('.z-user-tz').text();

    // We have to parse the string as a number for the Date object to accept it during the calculation:
    let num_tz = parseInt(user_tz);

    // And we have to do the same as well for the operator, since both will be combined in the 'offset' constant:
    let offset = (user_tz_operator === '-') ? -num_tz : num_tz;

    // Run the conversion through the function...
    let localDateTime = convertToLocalTime(utcDateTime, offset);

    // Populate the (appropriate, probably using .closest() and .find()) date/time BBcode area with a local datetime string: 
    $(".local-date-time").text(localDateTime);
  });

</script>

So like, it does actually work now. What I need to do next to finish this off is to do this for EACH instance of a UTC bbcode on the page. Would be simple if we were only expecting one of these, but it's common for multiple date/times to be expressed in a single post or on a single page. So yeah, that will involve looping through them using foreach or something like that.

Fingers crossed this might actually be possible guys! :cool:
Schnorki wrote: 1 year ago
Since the main reason for the request was walk schedules though, let me just shamelessly plug feedback/suggestion-upcoming-walks-t1188212.html here as an alternative since that could be built in a simpler way with select default-conversions shown (or linked to), avoiding all of that.
Looked it over a few times in the last week when collating bugs/requests, decided I wouldn't pursue it in 1.41.

7
User avatar

Teebling 6875Admin

Europe PC
Okay guys, well I did it :)

Here's what the [utctolocal][/utctolocal] BBcode will do next patch...

If you are a registered user, you will see this:
If you are a guest, you will see this:
Any other suggestions? Teeb

7
User avatar

Schnorki 3813Moderator

PC
Does the converted/unconverted string always appear?

Seems like a fairly long flag for cases where that code is used within posts.

Either way, well done figuring it out! :)
7
User avatar

Teebling 6875Admin

Europe PC
Schnorki wrote: 1 year ago
Seems like a fairly long flag for cases where that code is used within posts.
Yes, that string always shows. Agreed, only other way I could think of is a hover tooltip, but that won't display on mobile devices either so doesn't cover the whole userbase. Any idea how we could improve?

7
User avatar

Schnorki 3813Moderator

PC
Add a converted/not-converted small icon to it for the hover, make it clickable for mobile to get an explanation of what the icon means?
7
User avatar

Teebling 6875Admin

Europe PC
Cool, got that implemented now. Works well:
Members on Desktop will see a hover tooltip (Converted to Local)
Members on Desktop will see a hover tooltip (Converted to Local)
Members on Mobile will see a tappable info icon (Converted to Local)
Members on Mobile will see a tappable info icon (Converted to Local)
Guests on Desktop will see a hover tooltip (UTC)
Guests on Desktop will see a hover tooltip (UTC)
Guests on Mobile will see a tappable info icon (UTC)
Guests on Mobile will see a tappable info icon (UTC)

7
User avatar

Schnorki 3813Moderator

PC
Nice
9

Advertisment

Hide ads
999

Greetings stranger!

You don't appear to be logged in...

99

Who is online

Users browsing Feedback: No registered users and 11 guests.

No matches
 

 

 

 

Value:
Hide ads forever by supporting the site with a donation.

Greetings adblocker...

Warriv asks that you consider disabling your adblocker when using diablo2.io

Ad revenue helps keep the servers going and supports me, the site's creator :)

A one-time donation hides all ads, forever:
Make a donation