|
 |
|
 |
01-23-2006, 03:21 PM
|
#1 (permalink)
|
|
Moderator
Join Date: May 2002
Location: us.ca
Posts: 4,487
|
Sunrise, Sunset (with php)
I stumbled across some interesting functions last week.
date_sunrise()
date_sunset()
they return a unix timestamp of the sunrise and sunset in php5. kinda cool.
|
|
|
01-24-2006, 05:48 PM
|
#2 (permalink)
|
|
Jack of all trades
Join Date: Feb 2005
Location: Los Angeles
Posts: 598
|
Not to be negative or anything, but sometimes I wish more of php's builtin functions were library functions with real namespaces rather than prefix namespaces (eg Date:sunrise vs date_sunrise or MySQL:query vs mysql_query)
__________________
Stop intellectual property from infringing on me
|
|
|
01-24-2006, 06:27 PM
|
#3 (permalink)
|
|
Moderator
Join Date: May 2002
Location: us.ca
Posts: 4,487
|
why? then it would be called java or .net 
|
|
|
01-24-2006, 06:41 PM
|
#4 (permalink)
|
|
Jack of all trades
Join Date: Feb 2005
Location: Los Angeles
Posts: 598
|
I just like languages with small cores and good library support that's all. PHP's core does what good libraries do, but it's a pretty big core.
__________________
Stop intellectual property from infringing on me
|
|
|
01-24-2006, 06:51 PM
|
#5 (permalink)
|
|
Moderator
Join Date: May 2002
Location: us.ca
Posts: 4,487
|
I think PHP has both. A good core and then lots of other libraries you can add. Maybe it's not organized in namespaces, but they do organize similar functions in the PHP manual for reference.
I think PHP would not be PHP if it you had to do things like include a datetime namespace and instanciate a time object.
|
|
|
01-24-2006, 07:11 PM
|
#6 (permalink)
|
|
Jack of all trades
Join Date: Feb 2005
Location: Los Angeles
Posts: 598
|
I never said anything about objects! I was more thinking of the ways you add libraries in C or perl. But yeah php does have a sort of eclectic charm.
__________________
Stop intellectual property from infringing on me
|
|
|
01-24-2006, 07:14 PM
|
#7 (permalink)
|
|
Moderator
Join Date: May 2002
Location: us.ca
Posts: 4,487
|
oh my bad, i always associated namespaces with OO. it does have an addon library structure, but i suppose they are added per PHP installation vs at the application level.
|
|
|
02-02-2006, 09:03 PM
|
#8 (permalink)
|
|
$_['Your_Mom'];
Join Date: May 2002
Location: Santee
Posts: 627
|
that's neat
although i still run 4 cause i'm lame*
*lame = i dont want to break old scripts, hooray.
|
|
|
02-02-2006, 09:15 PM
|
#9 (permalink)
|
|
Moderator
Join Date: May 2002
Location: us.ca
Posts: 4,487
|
hey matt!
i haven't upgraded yet because i'm afraid to break hosting customer's sites. one of these days i'm just going to have to give plenty of warning and just do it.
|
|
|
02-03-2006, 04:22 AM
|
#10 (permalink)
|
|
Senior Contributor
Join Date: Mar 2005
Posts: 673
|
Perl alike ?
Code:
function use($classname)
{
include($classname.'.php');
}
use('datetime');
datetime::sunrise()
datetime::sunset()
Code:
class datetime
{
public static function sunrise()
{
return date_sunrise();
}
public static function sunset()
{
return date_sunset();
}
}
|
|
|
02-03-2006, 09:13 PM
|
#11 (permalink)
|
|
Jack of all trades
Join Date: Feb 2005
Location: Los Angeles
Posts: 598
|
The point isn't that I want to call it as library::function, it's just that the standard php namespace seems a little crowded sometimes. That's a neat trick though.
__________________
Stop intellectual property from infringing on me
|
|
|
04-11-2006, 06:17 AM
|
#12 (permalink)
|
|
Code Monkey
Join Date: Mar 2006
Location: Woodbury, CT
Posts: 38
|
These functions rock! I actually took some time to look up the underlying algorithms and, it's MUCH easier just to call this function. Now, if someone would come up with a function that could give moonrise and moonset . . . . THOSE calculations are freeky!!!!!
Frank
|
|
|
04-14-2006, 08:49 PM
|
#13 (permalink)
|
|
Registered User
Join Date: Apr 2006
Posts: 2
|
Eclectic ?
Quote:
|
Originally Posted by teknomage1
I never said anything about objects! I was more thinking of the ways you add libraries in C or perl. But yeah php does have a sort of eclectic charm.
|
Don't give in so easy !
Dave
|
|
|
04-14-2006, 09:07 PM
|
#14 (permalink)
|
|
Jack of all trades
Join Date: Feb 2005
Location: Los Angeles
Posts: 598
|
Hehe, welcome, Dave.
__________________
Stop intellectual property from infringing on me
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -8. The time now is 05:19 AM.
|
Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting
|
 |
|