NAME
Neo4j::Types::DateTime - Represents a Neo4j temporal instant value
VERSION
version 2.00
SYNOPSIS
$days = $dt->days;
$seconds = $dt->seconds;
$nanoseconds = $dt->nanoseconds;
$epoch = $days * 86400 + $seconds;
$epoch = $dt->epoch;
$epoch_hires = $epoch + $nanoseconds / 1e9;
$tz_name = $dt->tz_name; # like Europe/Paris
$seconds = $dt->tz_offset; # like 3600
$neo4j_type = $dt->type; # like ZONED DATETIME
DESCRIPTION
Represents a temporal instant value in Neo4j. Potentially includes date, time, and timezone components.
Neo4j offers the following temporal instant types:
DATE
LOCAL TIME
– no time zone informationZONED TIME
– has a time zone offset in secondsLOCAL DATETIME
– no time zone informationZONED DATETIME
– has a time zone offset in seconds, or a time zone name from the IANA Olson database
This interface is designed to closely match the semantics of the Neo4j temporal types. For actually working with dates and times in Perl, the modules recommended by Task::Kensho::Dates are better suited in most cases. The conversion is easiest using the Epoch value:
$dt = Neo4j::Types::Generic::DateTime->new( ... );
$epoch_hires = $dt->epoch + $dt->nanoseconds / 1e9;
$datetime = DateTime->from_epoch( epoch => $epoch_hires );
$moment = Time::Moment->from_epoch( $epoch_hires );
$piece = Time::Piece->new( $dt->epoch );
DateTime values may be returned from a Neo4j database server. Generic DateTime values may also be created locally. See "DateTime" in Neo4j::Types::Generic.
Supported in Neo4j version 3.4 and above.
METHODS
Neo4j::Types::DateTime specifies the following methods.
days
$days = $dt->days;
Return the number of full days since the Unix epoch. For * TIME
values, return undef
.
For the day identified by $days
, the Julian Date is exactly $days + 2440587.5
.
epoch
$seconds = $dt->epoch;
Return the full seconds since the Unix epoch, ignoring leap seconds. Values of the type TIME
are interpreted as referring to 1 January 1970.
nanoseconds
$nanoseconds = $dt->nanoseconds;
Return the nanoseconds since the start of the second identified by seconds()
. For DATE
values, return undef
.
seconds
$seconds = $dt->seconds;
Return the seconds since the start of the day. For DATE
values, return undef
.
type
$neo4j_type = $dt->type;
Return the Neo4j type name for this value as a string. One of DATE
, LOCAL TIME
, ZONED TIME
, LOCAL DATETIME
, ZONED DATETIME
.
tz_name
$tz_name = $dt->tz_name;
Return the name of the time zone to be used for display purposes. The name refers to the IANA Olson time zone database. For example, the time zone name for California would be America/Los_Angeles
. For DATE
values and LOCAL *
values, return undef
.
For a display time zone defined by standard offset only, this method will return a zone name in the Etc
area. Note that such zone names follow the POSIX sign convention, which uses a positive sign west of Greenwich. This is the inverse of the ISO convention usually used for time zone offsets.
tz_offset
$seconds = $dt->tz_offset;
Return the number of seconds to be added to the time for display purposes. A positive sign is used east of Greenwich. For example, for standard time in California, the offset from UTC would be -28800 seconds. For DATE
values and LOCAL *
values, return undef
.
To define a display time zone, it is sufficient for either the time zone name or a numerical time offset to be available. If this method returns undef
, you need to use tz_name()
instead.
SEE ALSO
AUTHOR
Arne Johannessen <ajnn@cpan.org>
If you contact me by email, please make sure you include the word "Perl" in your subject header to help beat the spam filters.
COPYRIGHT AND LICENSE
This software is Copyright (c) 2021-2023 by Arne Johannessen.
This is free software; you can redistribute it and/or modify it under the terms of the Artistic License 2.0 or (at your option) the same terms as the Perl 5 programming language system itself.