Automatic Daylight Savings Time (DST)

All new MODs released in our MOD Database will be announced in here. All support for released MODs needs to take place in the Customisations Database.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTICE: This forum is only for the announcement of new releases and/or updates of MODs. Any MOD support should be obtained through the Customisations Database in the support area designated for each MOD.

A direct link to support for each MOD is in the first post of the respective topic.
Locked
User avatar
MartectX
Translator
Posts: 1324
Joined: Wed Dec 19, 2007 8:05 pm
Location: Marienplatz

Re: Automatic Daylight Savings Time (DST)

Post by MartectX » Mon Dec 22, 2008 2:01 am

JeRicHoOL wrote:How can I uninstall the SQL command?

Code: Select all

UPDATE phpbb_config SET is_dynamic = 0 WHERE config_name = 'board_dst';
UPDATE phpbb_users SET user_dst = 0;
DragonMaster1 wrote:Most of my board users are in Europe and so I am wondering if this is worth installing?

Wouldn’t my changing the 1 hour forward or backward in the ACP do the same thing for everyone instead of each user having to reset their time?
There are disadvantages to every option: If you set it yourself it may not be the right setting for all of your users. If you let the server decide (which is what this MOD will do) this is also the case - but it's at least automatic and users can still enable and disable DST manually.

I wrote this MOD for my board where all live in the same timezone and twice a year there were complaints about the wrong board time - these complaints have stopped and I'm happy. If the MOD does not satisfy your needs it's regrettable but cannot be changed.

JeRicHoOL
Registered User
Posts: 449
Joined: Sun Jun 01, 2008 4:02 pm

Re: Automatic Daylight Savings Time (DST)

Post by JeRicHoOL » Mon Dec 22, 2008 2:35 am

Thank you MertecX. ;)
Maybe one day this mod will work for websites where the server is in another timezone.

User avatar
MartectX
Translator
Posts: 1324
Joined: Wed Dec 19, 2007 8:05 pm
Location: Marienplatz

Re: Automatic Daylight Savings Time (DST)

Post by MartectX » Mon Dec 22, 2008 2:49 am

JeRicHoOL wrote:Maybe one day this mod will work for websites where the server is in another timezone.
Not with the method I use with this MOD. And frankly - this DST nuisance I can't take it anymore. The problem is solved for me and I'm (as said in my last post) quite happy with the results. I share this MOD with all fellow phpBB3 admins as so many great MODs have been shared with me - most of which I do not use but am glad that they're out there nonetheless!

Isn't free software just great! :D

User avatar
MartectX
Translator
Posts: 1324
Joined: Wed Dec 19, 2007 8:05 pm
Location: Marienplatz

Re: Automatic Daylight Savings Time (DST)

Post by MartectX » Mon Dec 22, 2008 4:01 pm

I was thinking about the problem a bit more (sorry about my grumpiness earlier the day) and came up with an idea:

As the MOD works now, the admin can enable or disable Automatic DST from the ACP. This actually makes no sense - why should he ever deactivate it (if he would want to do that, he would not have installed the MOD to begin with!).

The option set for users stays the same:
"Settings for Automatic Daylight Savings Time:"
1.) Off
2.) On
3.) Automatic (new meaning: Let the Admin decide - not the server!!)

But I propose a new set of options for the admin:
"What is the DST setting for users that set their option to Automatic:"
1.) Off
2.) On (This forces DST even if your server is located on Mars)
3.) Server setting (This is how the MOD works right now)

User avatar
DragonMaster1
Registered User
Posts: 994
Joined: Tue Aug 17, 2004 11:04 am
Contact:

Re: Automatic Daylight Savings Time (DST)

Post by DragonMaster1 » Mon Dec 22, 2008 11:28 pm

If we could get all users setting to work properly with nothing to do on their part, that would be the best way

User avatar
MartectX
Translator
Posts: 1324
Joined: Wed Dec 19, 2007 8:05 pm
Location: Marienplatz

Re: Automatic Daylight Savings Time (DST)

Post by MartectX » Tue Dec 23, 2008 12:38 am

DragonMaster1 wrote:If we could get all users setting to work properly with nothing to do on their part, that would be the best way
How would you go about it, then?

User avatar
DragonMaster1
Registered User
Posts: 994
Joined: Tue Aug 17, 2004 11:04 am
Contact:

Re: Automatic Daylight Savings Time (DST)

Post by DragonMaster1 » Tue Dec 23, 2008 4:34 am

No idea...that is why I was using a mod :mrgreen:

dgroeser
Registered User
Posts: 22
Joined: Sat Apr 19, 2008 10:20 am

Re: Automatic Daylight Savings Time (DST)

Post by dgroeser » Tue Dec 23, 2008 11:43 am

The Mod works perfekt, but in the Board Settings would be shown the summertime overall woud be shown the wintertime?

User avatar
MartectX
Translator
Posts: 1324
Joined: Wed Dec 19, 2007 8:05 pm
Location: Marienplatz

Re: Automatic Daylight Savings Time (DST)

Post by MartectX » Tue Dec 23, 2008 11:50 am

dgroeser wrote:The Mod works perfekt, but in the Board Settings would be shown the summertime overall woud be shown the wintertime?
Admin Board Settings or User Board Settings?

JirkaX
Registered User
Posts: 169
Joined: Tue Apr 15, 2008 8:12 am

Re: Automatic Daylight Savings Time (DST)

Post by JirkaX » Mon Dec 29, 2008 5:35 pm

Hi, I upated my forum to version 3.0.4, I did recommended change (adding 1 line), but I receive errors below:

Code: Select all

[phpBB Debug] PHP Notice: in file /includes/session.php on line 2096: strtr() [function.strtr]: The second argument is not an array.
[phpBB Debug] PHP Notice: in file /includes/session.php on line 2096: strtr() [function.strtr]: The second argument is not an array.
[phpBB Debug] PHP Notice: in file /includes/session.php on line 2096: strtr() [function.strtr]: The second argument is not an array.
[phpBB Debug] PHP Notice: in file /includes/session.php on line 2096: strtr() [function.strtr]: The second argument is not an array.
[phpBB Debug] PHP Notice: in file /includes/session.php on line 2096: strtr() [function.strtr]: The second argument is not an array.
[phpBB Debug] PHP Notice: in file /includes/session.php on line 2096: strtr() [function.strtr]: The second argument is not an array.
[phpBB Debug] PHP Notice: in file /includes/session.php on line 2096: strtr() [function.strtr]: The second argument is not an array.
[phpBB Debug] PHP Notice: in file /includes/session.php on line 2096: strtr() [function.strtr]: The second argument is not an array.
[phpBB Debug] PHP Notice: in file /includes/session.php on line 2096: strtr() [function.strtr]: The second argument is not an array.
[phpBB Debug] PHP Notice: in file /includes/session.php on line 2096: strtr() [function.strtr]: The second argument is not an array.
[phpBB Debug] PHP Notice: in file /includes/session.php on line 2096: strtr() [function.strtr]: The second argument is not an array.
[phpBB Debug] PHP Notice: in file /includes/session.php on line 2096: strtr() [function.strtr]: The second argument is not an array.
[phpBB Debug] PHP Notice: in file /includes/session.php on line 2096: strtr() [function.strtr]: The second argument is not an array.
[phpBB Debug] PHP Notice: in file /includes/session.php on line 2096: strtr() [function.strtr]: The second argument is not an array.
[phpBB Debug] PHP Notice: in file /includes/session.php on line 2096: strtr() [function.strtr]: The second argument is not an array.
[phpBB Debug] PHP Notice: in file /includes/session.php on line 2096: strtr() [function.strtr]: The second argument is not an array.
[phpBB Debug] PHP Notice: in file /includes/session.php on line 2096: strtr() [function.strtr]: The second argument is not an array.
[phpBB Debug] PHP Notice: in file /includes/session.php on line 2096: strtr() [function.strtr]: The second argument is not an array.
[phpBB Debug] PHP Notice: in file /includes/session.php on line 2096: strtr() [function.strtr]: The second argument is not an array.
[phpBB Debug] PHP Notice: in file /includes/session.php on line 2096: strtr() [function.strtr]: The second argument is not an array.
[phpBB Debug] PHP Notice: in file /includes/session.php on line 2096: strtr() [function.strtr]: The second argument is not an array.
[phpBB Debug] PHP Notice: in file /includes/session.php on line 2096: strtr() [function.strtr]: The second argument is not an array.
[phpBB Debug] PHP Notice: in file /includes/session.php on line 2096: strtr() [function.strtr]: The second argument is not an array.
[phpBB Debug] PHP Notice: in file /includes/session.php on line 2096: strtr() [function.strtr]: The second argument is not an array.
[phpBB Debug] PHP Notice: in file /includes/session.php on line 2096: strtr() [function.strtr]: The second argument is not an array.
[phpBB Debug] PHP Notice: in file /includes/session.php on line 2096: strtr() [function.strtr]: The second argument is not an array.
[phpBB Debug] PHP Notice: in file /includes/session.php on line 2096: strtr() [function.strtr]: The second argument is not an array.
[phpBB Debug] PHP Notice: in file /includes/session.php on line 2096: strtr() [function.strtr]: The second argument is not an array.
[phpBB Debug] PHP Notice: in file /includes/session.php on line 2096: strtr() [function.strtr]: The second argument is not an array.
[phpBB Debug] PHP Notice: in file /includes/session.php on line 2096: strtr() [function.strtr]: The second argument is not an array.
[phpBB Debug] PHP Notice: in file /includes/session.php on line 2096: strtr() [function.strtr]: The second argument is not an array.
[phpBB Debug] PHP Notice: in file /includes/session.php on line 2096: strtr() [function.strtr]: The second argument is not an array.
[phpBB Debug] PHP Notice: in file /includes/session.php on line 2096: strtr() [function.strtr]: The second argument is not an array.
[phpBB Debug] PHP Notice: in file /includes/session.php on line 2096: strtr() [function.strtr]: The second argument is not an array.
[phpBB Debug] PHP Notice: in file /includes/session.php on line 2096: strtr() [function.strtr]: The second argument is not an array.
[phpBB Debug] PHP Notice: in file /includes/session.php on line 2096: strtr() [function.strtr]: The second argument is not an array.
[phpBB Debug] PHP Notice: in file /includes/session.php on line 2096: strtr() [function.strtr]: The second argument is not an array.
[phpBB Debug] PHP Notice: in file /includes/session.php on line 2096: strtr() [function.strtr]: The second argument is not an array.
[phpBB Debug] PHP Notice: in file /includes/session.php on line 2096: strtr() [function.strtr]: The second argument is not an array.
[phpBB Debug] PHP Notice: in file /includes/session.php on line 2096: strtr() [function.strtr]: The second argument is not an array.
[phpBB Debug] PHP Notice: in file /includes/session.php on line 2096: strtr() [function.strtr]: The second argument is not an array.
[phpBB Debug] PHP Notice: in file /includes/session.php on line 2096: strtr() [function.strtr]: The second argument is not an array.
[phpBB Debug] PHP Notice: in file /includes/session.php on line 2096: strtr() [function.strtr]: The second argument is not an array.
[phpBB Debug] PHP Notice: in file /includes/session.php on line 2096: strtr() [function.strtr]: The second argument is not an array.
[phpBB Debug] PHP Notice: in file /includes/session.php on line 2096: strtr() [function.strtr]: The second argument is not an array.
[phpBB Debug] PHP Notice: in file /includes/session.php on line 2096: strtr() [function.strtr]: The second argument is not an array.
[phpBB Debug] PHP Notice: in file /includes/session.php on line 2096: strtr() [function.strtr]: The second argument is not an array.
[phpBB Debug] PHP Notice: in file /includes/session.php on line 2096: strtr() [function.strtr]: The second argument is not an array.
[phpBB Debug] PHP Notice: in file /includes/session.php on line 2096: strtr() [function.strtr]: The second argument is not an array.
[phpBB Debug] PHP Notice: in file /includes/session.php on line 2096: strtr() [function.strtr]: The second argument is not an array.
[phpBB Debug] PHP Notice: in file /includes/session.php on line 2096: strtr() [function.strtr]: The second argument is not an array.
[phpBB Debug] PHP Notice: in file /includes/session.php on line 2096: strtr() [function.strtr]: The second argument is not an array.
[phpBB Debug] PHP Notice: in file /includes/session.php on line 2096: strtr() [function.strtr]: The second argument is not an array.
[phpBB Debug] PHP Notice: in file /includes/session.php on line 2096: strtr() [function.strtr]: The second argument is not an array.
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3908: Cannot modify header information - headers already sent by (output started at /includes/functions.php:3223)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3910: Cannot modify header information - headers already sent by (output started at /includes/functions.php:3223)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3911: Cannot modify header information - headers already sent by (output started at /includes/functions.php:3223)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3912: Cannot modify header information - headers already sent by (output started at /includes/functions.php:3223)
Do you know any reason for this? When I use session.php from previous version (3.0.3), everything works.

My new session.php find here: http://www.belariepark.cz/down/session_file.rar
Last edited by JirkaX on Thu Jan 01, 2009 10:29 am, edited 1 time in total.

User avatar
MartectX
Translator
Posts: 1324
Joined: Wed Dec 19, 2007 8:05 pm
Location: Marienplatz

Re: Automatic Daylight Savings Time (DST)

Post by MartectX » Mon Dec 29, 2008 6:45 pm

FIND

Code: Select all

	function format_date($gmepoch, $format = false, $forcedate = false)
	{
		static $midnight;
		static $date_cache;

		$format = (!$format) ? $this->date_format : $format;
		$now = time();
		$delta = $now - $gmepoch;

		if (!isset($date_cache[$format]))
		{
			// Is the user requesting a friendly date format (i.e. 'Today 12:42')?
			$date_cache[$format] = array(
				'is_short'		=> strpos($format, '|'),
				'zone_offset'	=> $this->timezone + $this->dst,
				'format_short'	=> substr($format, 0, strpos($format, '|')) . '||' . substr(strrchr($format, '|'), 1),
				'format_long'	=> str_replace('|', '', $format),
				'lang'			=> $this->lang['datetime'],
			);

			// Short representation of month in format? Some languages use different terms for the long and short format of May
			if ((strpos($format, '\M') === false && strpos($format, 'M') !== false) || (strpos($format, '\r') === false && strpos($format, 'r') !== false))
			{
				$date_cache[$format]['lang']['May'] = $this->lang['datetime']['May_short'];
			}
		}

          // This will determine the correct DST setting for every date, should a user wish for automatic detection
          $date_cache[$format]['zone_offset'] = ($this->data['user_dst'] == DST_AUTO) ? $this->timezone + date('I', $gmepoch) * 3600 : $this->timezone + $this->dst;


		unset($lang_dates['May_short']);

		if (!$midnight)
		{
			list($d, $m, $y) = explode(' ', gmdate('j n Y', time() + $this->timezone + $this->dst));
			$midnight = gmmktime(0, 0, 0, $m, $d, $y) - $this->timezone - $this->dst;
		}

		if (strpos($format, '|') === false || ($gmepoch < $midnight - 86400 && !$forcedate) || ($gmepoch > $midnight + 172800 && !$forcedate))
		{
			return strtr(@gmdate(str_replace('|', '', $format), $gmepoch + $this->timezone + $this->dst), $lang_dates);
		}

		if ($gmepoch > $midnight + 86400 && !$forcedate)
		{
			$format = substr($format, 0, strpos($format, '|')) . '||' . substr(strrchr($format, '|'), 1);
			return str_replace('||', $this->lang['datetime']['TOMORROW'], strtr(@gmdate($format, $gmepoch + $this->timezone + $this->dst), $lang_dates));
		}
		else if ($gmepoch > $midnight && !$forcedate)
		{
			$format = substr($format, 0, strpos($format, '|')) . '||' . substr(strrchr($format, '|'), 1);
			return str_replace('||', $this->lang['datetime']['TODAY'], strtr(@gmdate($format, $gmepoch + $this->timezone + $this->dst), $lang_dates));
		}
		else if ($gmepoch > $midnight - 86400 && !$forcedate)
		{
			$format = substr($format, 0, strpos($format, '|')) . '||' . substr(strrchr($format, '|'), 1);
			return str_replace('||', $this->lang['datetime']['YESTERDAY'], strtr(@gmdate($format, $gmepoch + $this->timezone + $this->dst), $lang_dates));
		}

		return strtr(@gmdate(str_replace('|', '', $format), $gmepoch + $this->timezone + $this->dst), $lang_dates);
		
	}
REPLACE WITH

Code: Select all

	function format_date($gmepoch, $format = false, $forcedate = false)
	{
		static $midnight;
		static $date_cache;

		$format = (!$format) ? $this->date_format : $format;
		$now = time();
		$delta = $now - $gmepoch;

		if (!isset($date_cache[$format]))
		{
			// Is the user requesting a friendly date format (i.e. 'Today 12:42')?
			$date_cache[$format] = array(
				'is_short'		=> strpos($format, '|'),
				'zone_offset'	=> $this->timezone + $this->dst,
				'format_short'	=> substr($format, 0, strpos($format, '|')) . '||' . substr(strrchr($format, '|'), 1),
				'format_long'	=> str_replace('|', '', $format),
				'lang'			=> $this->lang['datetime'],
			);

			// Short representation of month in format? Some languages use different terms for the long and short format of May
			if ((strpos($format, '\M') === false && strpos($format, 'M') !== false) || (strpos($format, '\r') === false && strpos($format, 'r') !== false))
			{
				$date_cache[$format]['lang']['May'] = $this->lang['datetime']['May_short'];
			}
		}

		// This will determine the correct DST setting for every date, should a user wish for automatic detection
		$date_cache[$format]['zone_offset'] = ($this->data['user_dst'] == DST_AUTO) ? $this->timezone + date('I', $gmepoch) * 3600 : $this->timezone + $this->dst;

		// Show date <= 1 hour ago as 'xx min ago'
		// A small tolerence is given for times in the future and times in the future but in the same minute are displayed as '< than a minute ago'
		if ($delta <= 3600 && ($delta >= -5 || (($now / 60) % 60) == (($gmepoch / 60) % 60)) && $date_cache[$format]['is_short'] !== false && !$forcedate && isset($this->lang['datetime']['AGO']))
		{
			return $this->lang(array('datetime', 'AGO'), max(0, (int) floor($delta / 60)));
		}

		if (!$midnight)
		{
			list($d, $m, $y) = explode(' ', gmdate('j n Y', time() + $date_cache[$format]['zone_offset']));
			$midnight = gmmktime(0, 0, 0, $m, $d, $y) - $date_cache[$format]['zone_offset'];
		}

		if ($date_cache[$format]['is_short'] !== false && !$forcedate)
		{
			$day = false;

			if ($gmepoch > $midnight + 86400)
			{
				$day = 'TOMORROW';
			}
			else if ($gmepoch > $midnight)
			{
				$day = 'TODAY';
			}
			else if ($gmepoch > $midnight - 86400)
			{
				$day = 'YESTERDAY';
			}

			if ($day !== false)
			{
				return str_replace('||', $this->lang['datetime'][$day], strtr(@gmdate($date_cache[$format]['format_short'], $gmepoch + $date_cache[$format]['zone_offset']), $date_cache[$format]['lang']));
			}
		}

		return strtr(@gmdate($date_cache[$format]['format_long'], $gmepoch + $date_cache[$format]['zone_offset']), $date_cache[$format]['lang']);
	}

JirkaX
Registered User
Posts: 169
Joined: Tue Apr 15, 2008 8:12 am

Re: Automatic Daylight Savings Time (DST)

Post by JirkaX » Mon Dec 29, 2008 7:10 pm

great, thanks for your help

I have 2 questions regarding function:
- in ACP "Set summer time" should be set to On or Off?
- in UCP "Summer Time is in effect" should be set by user or it is done automatically?

User avatar
MartectX
Translator
Posts: 1324
Joined: Wed Dec 19, 2007 8:05 pm
Location: Marienplatz

Re: Automatic Daylight Savings Time (DST)

Post by MartectX » Mon Dec 29, 2008 7:24 pm

JirkaX wrote:I have 2 questions regarding function:
- in ACP "Set summer time" should be set to On or Off?
- in UCP "Summer Time is in effect" should be set by user or it is done automatically?
If you have done the installation correctly it should be:

ACP: Set Automatic Summer Time: ON / OFF
UCP: Summer Time is in effect: ON / OFF / AUTOMATIC

I recommend the settings in bold letters.

JirkaX
Registered User
Posts: 169
Joined: Tue Apr 15, 2008 8:12 am

Re: Automatic Daylight Savings Time (DST)

Post by JirkaX » Mon Dec 29, 2008 8:11 pm

unfortunately I installed this MOD a few month ago, so now I did only updates, but I had only these 2 options in UCP - On and Off. So I went through install file and did other changes. Now it seems to be working ...

But I think we will see the real functionality in the spring during the next time change:-)

But thanks again for your help with session.php

User avatar
IPB_Refugee
Registered User
Posts: 1290
Joined: Fri Jul 07, 2006 2:25 pm
Location: Austria
Name: Wolfgang Weber

Re: Automatic Daylight Savings Time (DST)

Post by IPB_Refugee » Fri Jan 02, 2009 2:15 am

Hi Martin,

I'm located GMT+1, but the server is somewhere in the US (GMT-x hours).

Did I understand you correctly that it will be possible to use your MOD even in the case I mentioned above?

That would be great. It was possible with phpBB-2, so it might be possible with phpBB-3 again (?)

Wish you the best for 2009!
Wolfgang

Locked

Return to “[3.0.x] MOD Database Releases”

Who is online

Users browsing this forum: No registered users and 16 guests