Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^2: High-speed Date Formatting

by rjt (Deacon)
on Jul 12, 2013 at 08:34 UTC ( #1043905=note: print w/replies, xml ) Need Help??


in reply to Re: High-speed Date Formatting
in thread *SOLVED* High-speed Date Formatting

Great idea! In fact, I had the same one earlier in this thread at least six hours ago. :-) Here's the relevant sub by itself:

use Inline C => q@ int epoch_sec(char * date) { char *tz_str = date + 26; struct tm tm; int tz; if ( strlen(date) != 31 || strptime(date, "%a, %d %b %Y %T", &tm) == NULL || sscanf(tz_str, "%d", &tz) != 1) { printf("Invalid date %s\n", date); return 0; } return timegm(&tm) - (tz < 0 ? -1 : 1)*(abs(tz)/100*3600 + abs(tz)%100*60); } @;

Performs about 25 times faster than str2time.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1043905]
help
Chatterbox?
[robby_dobby]: LanX: Sharm-el-Sheikh is in Egypt
[choroba]: act.yapc.eu
[robby_dobby]: Thanks, choroba
[LanX]: yes and Egypt (like Turkey and Russia) belongs to two continents
[choroba]: Also Europe and Asia are geographically one continent, the division is political
[robby_dobby]: I always thought everything on the other side of Suez to be Africa. That's an entire continent
[LanX]: Sinai_Peninsula
[robby_dobby]: choroba: If you're talking of Eurasia, it's only true of the erstwhile Constantinople/ Ottoman empire
[LanX]: yes correct, but Sinai is not on the other side
[LanX]: Organizing a YAPC in a tourist ressort is not a bad idea ...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (15)
As of 2017-04-24 16:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (442 votes). Check out past polls.