Jump to content

PHP question


CrashGordon

Recommended Posts

I've been looking around the code in app.config.php and spotted this.

Config::Set('DAYS_COMPACT',  array('Su', 'M', 'T', 'W', 'Th', 'F', 'S', 'Su'));

Config::Set('DAYS_LONG', 
array('Sunday',
'Monday',
'Tuesday',
'Wednesday',
'Thursday',
'Friday',
'Saturday',
'Sunday'
)
);

I know as much about PHP as I know about quantum mechanics, so I am curious as to why Sunday/Su is in the array twice. Sorry if this is a dumb question.

Link to comment
Share on other sites

  • Administrators

I am not 100% sure but I think Nabeel built it that way to try and combat the 0123456 and 1234567 issues with flight schedules and the sql tables and the excell import file where 0 or 7 could be a Sunday. I think..... :blink:

and Crash, if you figure out how to add a Sunday to the weekend, please let me know, I have lost a lot of hair trying to figure it out. :unsure:

Link to comment
Share on other sites

  • Administrators

Yup to account for 0 being Sunday, and if 7 is used for Sunday. PHP uses 0 for Sunday with date('w'). It's in there twice since array numbering starts from 0, so the first Sunday is 0, Monday 1... then on through the 2nd Sunday in which ends up being 7. Which is why you enter the dates with 0-7, it's easy to map to the name that way.

I added a line in the importer to replace any 7's with 0's so then you can use 1-7. The Sunday was in there twice for if you did use 1-7, it would show up properly, but I didn't realize date('w') returns 0 for a Sunday. Here's the fix (at least the schedule view piece, which I also added into schedule_results.tpl for the next):

http://forum.phpvms....dpost__p__17915

But any imports should now convert 7s to 0s (as of 932/next update this week)

Link to comment
Share on other sites

Tried that. Excel always tells me that if I save as a csv, I will lose all formating. Sure enough, the saved file never has the leading zero.

Just thought of something. I could open the file with a text editor and replace all 123456 with 0123456. That wouldn'

t work for those that weren't scheduled for all days. but would relieve me of a lot of subsequent editing.

Link to comment
Share on other sites

  • Moderators

I never think outside the box. I probably wouldn't have thought of doing that in a thousand years.unsure.gif

I useally leave the days of week blank and when i upload it, it will auto fill everyday format.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...