HEX
Server: Apache
System: Linux iad1-shared-b8-33 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User: samfetchero1 (10301780)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/share/doc/libdatetime-format-builder-perl/examples/Fall.pm
#!/usr/bin/perl -w
use strict;

=pod

This example shows a simple fall through parser that tries
a few of the other formatting modules, _then_ fails.

=cut

package DateTime::Format::Fall;
use DateTime::Format::HTTP;
use DateTime::Format::Mail;
use DateTime::Format::IBeat;

use DateTime::Format::Builder (
    parsers => {
        parse_datetime => [
            sub {
                eval { DateTime::Format::HTTP->parse_datetime( $_[1] ) };
            },
            sub {
                eval { DateTime::Format::Mail->parse_datetime( $_[1] ) };
            },
            sub {
                eval { DateTime::Format::IBeat->parse_datetime( $_[1] ) };
            },
        ]
    }
);

package main;

for ( '@d19.07.03 @704', '20030719T155345', 'gibberish' ) {
    print DateTime::Format::Fall->parse_datetime($_)->datetime, "\n";
}