Raised This Month: $ Target: $400
 0% 

Stock: IsDateInPast


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
mcpan313
Senior Member
Join Date: Mar 2010
Old 03-11-2012 , 10:11   Re: Stock: IsDateInPast
Reply With Quote #1

PHP Code:
// GET GMT TIME

public OnSocketConnected(Handle:socketany:arg)
{
    
decl String:requestStr[100];
    
Format(requestStrsizeof(requestStr), "GET /%s HTTP/1.0\r\nHost: %s\r\nConnection: Close\r\n\r\n""index.php""www.baidu.com");
    
SocketSend(socketrequestStr);
}

public 
OnSocketReceive(Handle:socketString:receiveData[], const dataSizeany:arg)
{
    
decl String:buffer[2][40];
    
ExplodeString(receiveData"\r\n"buffersizeof(buffer), sizeof(buffer[]));
    if (
StrContains(buffer[1], "Date:"false) != -1)
    {
        
decl String:date[5][5];
        
ExplodeString(buffer[1], " "datesizeof(date), sizeof(date[]));
        static 
String:month[12][4]={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};
        
        for (new 
isizeof(month); i++)
        {
            if (
StrEqual(date[3], month[i], false))
            {
                new 
current[3];
                
current[0] = StringToInt(date[4]);
                
current[1] = i+1;
                
current[2] = StringToInt(date[2]);
                
                static 
expires[3]={2011,4,8};
                new 
bool:available = (expires[0] > current[0] || (expires[0] == current[0] && expires[1] > current[1] || (expires[1] == current[1] && expires[2] >= current[2])));
                
                
PrintToServer("Current : %d-%02d-%02d"current[0], current[1], current[2]);
                
PrintToServer("Expires : %d-%02d-%02d"expires[0], expires[1], expires[2]);
                
PrintToServer("Status  : %s"available "正常" "已过期");
            }
        }
    }

PHP Code:
GET /index.php HTTP/1.0
Host
www.baidu.com
Connection
Close

HTTP
/1.1 200 OK
Date
Thu08 Mar 2012 08:29:07 GMT
Server
BWS/1.0
Content
-Length7909
Content
-Typetext/html;charset=gb2312
Cache
-Control: private
ExpiresThu08 Mar 2012 08:29:07 GMT
Set
-CookieBAIDUID=7ABE9EC447428E163F78633173D8425B:FG=1expires=Thu08-Mar-42 08:29:07 GMTpath=/; domain=.baidu.com
P3P
CP=" OTI DSP COR IVA OUR IND COM "
ConnectionClose 
__________________
sorry, for my poor english.

Last edited by mcpan313; 03-11-2012 at 10:18.
mcpan313 is offline
Send a message via MSN to mcpan313
robin123
Junior Member
Join Date: Mar 2012
Old 03-12-2012 , 15:34   Re: Stock: IsDateInPast
Reply With Quote #2

Nice code, it looks clean and easy to implement. Thanks for sharing we have been working on an extended project that calculates time, cost, and too much more to get into.
robin123 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 18:38.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode