Hello,

thanks for a great module, it has been really helpful

I've noticed one little problem with match time though. It seems that match time use server time but my server is in States and I'm in Europe and there is 7 hours difference. So if my match is created to start at 14:00, then on the match node, start time is displayed as 21:00.

Wonder if there is a quick fix for this?

Comments

Alun’s picture

Assigned: Unassigned » Alun

Hmm, yeah I think I remember using UNIX_TIMESTAMP() in a SQL call.
There is probably a way to use Drupal settings instead of the server time. I'll look into it and get back to you when I can.
Thanks for pointing this out.
Alun

ericpfeifer’s picture

Title: Server time » Adding a Standings Key
Component: Code » User interface
Category: support » feature

I have a simple request...

1. I know there is views integration now in alpha 3 but cant find any documentation on where the views are or how to import them or modify the existing one.

2. Is there a way to understand what the standings headings are? There isn't a key included anywhere in the documentation or on the standings page.

Keep up the great work on this module!

Alun’s picture

Title: Adding a Standings Key » Server time
Component: User interface » Code
Category: feature » support

eric,

1. As for Views integration, there are now fields available in Views, but I haven't created any pre-packaged views to export with the module as of yet, so you would have to create a view from scratch. I will create some for a future release, but due to the small amounts of time here and there I get to create the module, it isn't a priority. Maybe another user of Leaguesite would be kind enough to send you their exported view?

2. Sorry, again this is me being lazy and cracking on with the functionality of the module, not the user interface. The key is
P = Played
W = Won
L = Lost
D = Drawn
F = Points For
A = Points Against
Pts = Points.

Thats off the top of my head, so I hope its right! More options for this display will be added before a proper release (which is something I say a lot, I know!) but because of the Views integration, its not my priority.

Also, please open a new issue for a separate topic next time, it keeps things simple, as an issue queue is for one issue only!

Hope that helps.
Thanks
Alun

Alun’s picture

Status: Active » Needs review
StatusFileSize
new1.33 KB

perke, can you apply this patch and let me know if this fixes your problem please?
Thanks
Alun

perke’s picture

hey Alun,

thanks for quick response... first, i was getting errors on applying patch (i'm on win machine, using Tortoise) it was something about different chunk file size... then, I manually edited leaguesite_match.module and added a code from patch (changed lines 272 and 273)

created new match node with default time (14:00) but it came up as Thursday, January 1, 1970 - 00:00 (which is Epoch, i think :)

I see you're using some custom date format in here, could that be a issue?

Alun’s picture

Cool, it might be my fault with the patch, depends which version of the module you are using I guess.
The custom format just turns the time into a timestamp, which is how I am storing the match. Can you show me the lines of code you changed? say the lines between 265 and 280 or something. I can see if the code is the same as how I have it - I tried it on my website and it seems to work OK!
Thanks
Alun

perke’s picture

Here is the complete leaguesite_match_insert function

function leaguesite_match_insert($node){
  //add the extra details
	if($node->home_score != '' && $node->away_score != '' && variable_get('leaguesite_match_update_table_insert', '') == TRUE){
    _leaguesite_match_update_table($node->home_team, $node->away_team, $node->home_score, $node->away_score, $node->season_league);
    $is_result = 1;
	}
	//TODO: use this hook
	module_invoke_all('leaguesite_match_insert', $node);
  $match_time = format_date($match_time, 'custom', 'U');
   db_query("INSERT INTO {leaguesite_match} (nid, home_team, away_team, match_time, home_score, away_score, is_result, relation_id) VALUES (%d, %d, %d, %d, '%s', '%s', %d, %d)", intval($node->nid), intval($node->home_team), intval($node->away_team), check_plain($match_time), check_plain($node->home_score), check_plain($node->away_score), intval($is_result), intval($node->season_league));
 }
Alun’s picture

That explains it - you are missing this line

$match_time = mktime($node->match_hour, $node->match_minute, 0, intval($node->match_time['month']), intval($node->match_time['day']), intval($node->match_time['year']));

just before

$match_time = format_date($match_time, 'custom', 'U');

If you add it, that should get it working.

perke’s picture

hm, no luck... i'm still getting +7 hours difference between time on edit form and time on node... tried running update.php before creating new node, too

Just to make sure we're looking at the same version, I'm on 6.x-1.0-alpha3 ?

Alun’s picture

Well, this isn't a fun problem! I think I might have to overhaul the code and use Date API here, as timezones seem to be a weak point. For the time being, I think I will change the code to completely avoid timezone handling, and then see if I can apply a proper fix using Date API at a later date. I'll be back soon and let you know when I have committed this to the code.

Alun’s picture

Actually, this is horrible to fix. It'll take longer than 'soon' lol!

perke’s picture

Status: Needs review » Needs work

no probs, Alun.. keep up the good work. I'll just have to calculate time difference and enter it that way. No big deal but it would be awesome to move to Date API as it is the way to go. Wish I can contribute more as it look as a great module. I might post a use case though, once we're done with our site (it's a football team site).

Good luck and thanks again

Alun’s picture

I have attached a message from DeLaPena to this post, can someone look into it if they have the time and see if it does indeed fix the problem?
I would try myself, but I have no time whatsoever to sort it out at the moment, unfortunately, so it might be faster to post it here.
Thanks guys - I'll try and get a fix when time permits if no one can help with the PHP editing.

I think i may have found a solution for the date problem:

I used this function to convert a UNIX time stamp to a string in the format of YYYY-MM-DD:

$dateSQL = format_date($dateUnix, 'custom', 'Y-m-d');

This worked however if the user's timezone was different from the server's then it changed the actual date.
In my case the user's timezone was -05:00GMT and the server was -04:00GMT which resulted in the date 2010-03-31 changing to 2010-04-01.
The solution was to include the $timezone argument however since I did not want to change the timezone I passed an argument of 0 (zero).

$dateSQL = format_date($dateUnix, 'custom', 'Y-m-d', 0);

I also used the following code in another case:

$datePretty = format_date($dateUnix, 'medium', '', 0);

Note that I needed to pass an empty string ('') for the third argument (or I could have used null). The value of my second argument did not require the third argument ($format) to be set however without a third argument I could not pass the fourth ($format) and it is harmless to pass a value for $format as it will simply be ignored.

grtz Tim

timbraeckman’s picture

I managed to fix this problem. I've sent the solution to Alun and wait for him to check if the code is ok. Maybe he'll add it in a new version :-)

timbraeckman’s picture

Mmm it seems like it's not fixed for dates at the end of this year. I guess it's because of summer time and winter time. Shit! This sucks :-(

emnzava’s picture

Dear DeLaPena,

Just a thought. i think if we can take a look at event module may be we can come up with another idea of how to solve this issue.

Regards.

timbraeckman’s picture

Bwax you mean check out how it works in that module and than try to do the same in leaguesite? It would be great to help out Alun with this problem.

emnzava’s picture

Dear Tim,

I thought of this because i see it's the way open-source do things. For example, date module borrowed technique of calculating time zone from event module because they found it the best way to go rather than starting from scratch while somebody else has already done it.

I think dealing with date issue, we are not moving away from leaguesite module because date is universal to any module that wants to use it. But sports league and fixtures is specific to leaguesite.

regards.

timbraeckman’s picture

Are you a coder bwax? It would be great if you found out what's wrong in the code.
I tried yesterday and thought i found the solution and i really did but today i added the matches for november and than i saw the hour was 1 hour different again. I guess it's something with summer and winter time.

emnzava’s picture

Am not that much into coding but i am trying, step by step.

I do work on it, if i'll find any solution i will share with you.

Regards.

timbraeckman’s picture

Great!

Alun’s picture

StatusFileSize
new10.33 KB

Right guys, I'm hoping to get this fixed this week, it would be nice.
Here is a patch to update leaguesite_match.module and leaguesite_match.admin
It will incorporate date API into the creation and editing of matches.

Can some people in different server locations please test it and get back to me with success/problems occurred please?

Bear in mind 2 things -
You need to install and enable Date Popup (from Date module)
This may change some times you have, so please backup your database and original files

Thanks for helping guys, looking forward to the feedback.
Alun

Alun’s picture

Status: Needs work » Needs review
timbraeckman’s picture

Alun just with phpmyadmin export all tables? and than also the whole leaguesite folder? I'll test it right away than!

Alun’s picture

Yeah that will let you backup everything. Its good practice to do it once in a while anyway.

timbraeckman’s picture

Hi Alun,

It seems it doesn't work. I ran update.php and i tried to edit a match and set the date/time and it writes 0 in the database!

And for adding new matches it shows 01/01/70 02:00 as date when i enter 18/08/2010 20:00

grtz Tim

Alun’s picture

StatusFileSize
new10.48 KB

Just updated the patch for the fix when inserting a new match.
Alun

Alun’s picture

It all seems to be working OK for me, on multiple websites on different servers, so I have just committed the code. You can download it as soon as it updates on Drupal.

PLEASE ENABLE DATE API BEFORE RUNNING UPDATE.PHP
Cheers!
Alun

timbraeckman’s picture

I hope drupal will update soon!

Alun’s picture

It usually does it overnight.

timbraeckman’s picture

Great so tomorrow morning i can add all my matches for sure? :-)

Alun’s picture

Lets hope so! I can't be sure if the timezone is working for everyone, but it works on two different servers I tested it in, in different timezones too.

timbraeckman’s picture

Still the same problem for me :-(
It works for matches in the near future but as soon as time goes to winter time, it does +1 again and sets in database +0100 instead of +0200

grtz Tim

perke’s picture

Status: Needs review » Reviewed & tested by the community

Hi Alun, thanks for the hard work... last dev snapshot has fixed my issue with match time so marking this as RTBC. I had no chance to check against timezones so not sure about that.

Also, here is the site where I use LeagueSite extensively http://www.fkzeljeznicar.com (Bosnian Premier Football League Champions) if you want to see implementations of your great module :)

There are 3 blocks in the right sidebar where LeagueSite is used, first block is upcoming match for my team, second is last match and league table block (link in the block footer leads to detailed table) is on the bottom of the right sidebar. There is also news ticker in the footer showing all the matches from last matchday (still need to sort the matchday views filter somehow, but that's another issue)

Thanks to everyone who participated and helped in this issue!

timbraeckman’s picture

Hi perke,

Great site! Mine will be launched soon too and i'll show it here too than.

I have some questions about your site though...

1. Did you create a match center? I mean a page which shows the result of a match with match report, yellow/red cards, goals, etc?
2. How did you manage to create the statistics page with goals, yellow and red cards using leaguesite?

Thanks in advance!

Tim

perke’s picture

Hi Tim,

thanks :)

1. nope... don't really have a need for that page, but I guess you could mess with views and see what options you have... I bet it could be done easily as LeagueSite have good views integration

2. I did not use the Players part of the LeagueSite for the players statistics... its a cck content type, leaguesite_player.module wasn't live when I started using LeagueSite and converting later wasn't an option

good luck with the site!

Alun’s picture

Glad its working for you Perke - I need to add some handlers in Views to show the time correctly, as it is stored in the database as UTC, and converted to the designated timezone when it is needed. Theoretically, a user in a different timezone viewing the time should see it converted to their timezone, if you have that feature available. Otherwise it defaults to the sites timezone. Quite a funky solution using Date API :-)
I'll mark it as fixed once the Views handler is done. But I am glad its nearly done!

timbraeckman’s picture

Yeah it really is fixed! :-) It works even for me and that was a big job wasn't it? :-) haha
Thanks for the great work on this!
However... i'm a bit confused now... is it working for me using the custom files or using the dev release?

grtz Tim

timbraeckman’s picture

Category: support » feature

I think i just need a view handler which takes care of the DST and this is fixed. Remember: i use those custom files.

timbraeckman’s picture

Status: Reviewed & tested by the community » Needs work

Hi Alun,

When viewing the edit screen of a match i see the hour of the match that it should be +2h. (i guess for my timezone).
And when looking at my view i created with all matches... the hours of the matches in winter are still +1 hour.

grtz Tim

Alun’s picture

Thought I'd update this thread, this issue is on my mind and I refuse to get alpha4 out until it is sorted. I have recently changed the way dates are stored on the database, scrapping timestamps, and the issue is resolved completely on my development version.

Unfortunately the issue still arises with Views as it requires dates to be supplied in timestamp format.
As a result, I am working on a custom views handler which will treat the date as a string, I'll set up all the custom formatting and will get all the date features available in Views sorted in a custom handler. I will commit the update as soon as I have met a few other issues, and written the handler, of course!

Alun’s picture

Category: feature » bug
Status: Needs work » Fixed

This works perfectly for me, I have just committed the changes - I am storing the time in ISO format and dropping UNIX timestamp.
Views handler to deal with the change is also included.
Please back up files and database before updating. I cannot stress this enough.
Thanks
Alun

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.