HEX
Server: Apache
System: Linux pdx1-shared-a1-38 6.6.104-grsec-jammy+ #3 SMP Tue Sep 16 00:28:11 UTC 2025 x86_64
User: mmickelson (3396398)
PHP: 8.1.31
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";
}