NAME

Data::OFN::Common::TimeMoment - OFN common data object for time moment.

SYNOPSIS

use Data::OFN::Common::TimeMoment;

my $obj = Data::OFN::Common::TimeMoment->new(%params);
my $date = $obj->date;
my $date_and_time = $obj->date_and_time;
my $flag_unspecified = $obj->flag_unspecified;

DESCRIPTION

Immutable data object for OFN (Otevřené formální normy) representation of time moment in the Czech Republic.

This object is actual with 2020-07-01 version of OFN basic data types standard.

METHODS

new

my $obj = Data::OFN::Common::TimeMoment->new(%params);

Constructor.

  • date

    Date object defined by DataTime.

    It's optional.

    Default value is undef.

  • date_and_time

    Date and time object defined by DataTime.

    It's optional.

    Default value is undef.

  • flag_unspecified

    Flag for definition that date isn't defined.

    It's required.

    Default value is 0.

Returns instance of object.

date

my $date = $obj->date;

Get date.

Returns DateTime instance.

date_and_time

my $date_and_time = $obj->date_and_time;

Get date and time

Returns DateTime instance.

flag_unspecified

my $flag_unspecified = $obj->flag_unspecified;

Get flag for unspecified date.

Returns bool value (0/1).

ERRORS

new():
        From Mo::utils::check_bool():
                Parameter 'flag_unspecified' must be a bool (0/1).
                        Value: %s
        From Mo::utils::check_isa():
                Parameter 'date' must be a 'DataTime' object.
                        Value: %s
                        Reference: %s
                Parameter 'date_and_time' must be a 'DataTime' object.
                        Value: %s
                        Reference: %s
        Parmaeter 'date' and 'flag_unspecified' could not be defined together.
        Parameter 'date' must have a hour value of zero.
        Parameter 'date' must have a minute value of zero.
        Parameter 'date' must have a second value of zero.
        Parmaeter 'date_and_time' and 'flag_unspecified' could not be defined together.
        Parameter 'date_and_time' should be a 'date' parameter.
        Parameter 'flag_unspecified' disabled needs to be with 'date' or 'date_and_time' parameters.
        Parameters 'date' and 'date_and_time' could not be defined together.

EXAMPLE1

use strict;
use warnings;

use Data::OFN::Common::TimeMoment;
use DateTime;

my $obj = Data::OFN::Common::TimeMoment->new(
        'date' => DateTime->new(
                'day' => 8,
                'month' => 7,
                'year' => 2025,
        ),
);

print 'Date: '.$obj->date."\n";

# Output:
# Date: 2025-07-08T00:00:00

EXAMPLE2

use strict;
use warnings;

use Data::OFN::Common::TimeMoment;
use DateTime;

my $obj = Data::OFN::Common::TimeMoment->new(
        'date_and_time' => DateTime->new(
                'day' => 8,
                'month' => 7,
                'year' => 2025,
                'hour' => 12,
                'minute' => 10,
        ),
);

print 'Date and time: '.$obj->date_and_time."\n";

# Output:
# Date and time: 2025-07-08T12:10:00

DEPENDENCIES

Error::Pure Mo, Mo::utils.

REPOSITORY

https://github.com/michal-josef-spacek/Data-OFN-Common

AUTHOR

Michal Josef Špaček mailto:skim@cpan.org

http://skim.cz

LICENSE AND COPYRIGHT

© 2023-2025 Michal Josef Špaček

BSD 2-Clause License

VERSION

0.01