Perl Diver 2.33
Main Environment Variables Perl Default Values Perl Config - Summary Perl Config - Full Installed Modules List Directory uptime Docs

Module Documentation
Details and documentation about a specific module, including version and documentation (if available). Note that while links to perldoc.com and search.cpan.org are provided, the module may be part of a larger distribution. If you reach a File Not Found page on either site, please try the parent module.

BSON::Time

Name BSON::Time
Version v1.12.2
Located at /usr/share/perl5
File /usr/share/perl5/BSON/Time.pm
Is Core No
Search CPAN for this module BSON::Time
Documentation BSON::Time
Module Details BSON::Time


NAME

BSON::Time - BSON type wrapper for date and time


VERSION

version v1.12.2


SYNOPSIS

    use BSON::Types ':all';
    bson_time();        # now
    bson_time( $secs ); # floating point seconds since epoch


DESCRIPTION

This module provides a BSON type wrapper for a 64-bit date-time value in the form of milliseconds since the Unix epoch (UTC only).

On a Perl without 64-bit integer support, the value must be a the Math::BigInt manpage object.


ATTRIBUTES

value

A integer representing milliseconds since the Unix epoch. The default is 0.


METHODS

epoch

Returns the number of seconds since the epoch (i.e. a floating-point value).

as_iso8601

Returns the value as an ISO-8601 formatted string of the form YYYY-MM-DDThh:mm:ss.sssZ. The fractional seconds will be omitted if they are zero.

as_datetime

Loads DateTime and returns the value as a DateTime object.

as_datetime_tiny

Loads the DateTime::Tiny manpage and returns the value as a the DateTime::Tiny manpage object.

as_mango_time

Loads the Mango::BSON::Time manpage and returns the value as a the Mango::BSON::Time manpage object.

as_time_moment

Loads the Time::Moment manpage and returns the value as a the Time::Moment manpage object.

TO_JSON

Returns a string formatted by as_iso8601.

If the BSON_EXTJSON option is true, it will instead be compatible with MongoDB's extended JSON format, which represents it as a document as follows:

If the BSON_EXTJSON environment variable is true and the BSON_EXTJSON_RELAXED environment variable is false, returns a hashref compatible with MongoDB's extended JSON format, which represents it as a document as follows:

    {"$date" : { "$numberLong": "22337203685477580" } }

If the BSON_EXTJSON and BSON_EXTJSON_RELAXED environment variables are both true, then it will return a hashref with an ISO-8601 string for dates after the Unix epoch and before the year 10,000 and a $numberLong style value otherwise.

    {"$date" : "2012-12-24T12:15:30.500Z"}
    {"$date" : { "$numberLong": "-10000000" } }


OVERLOADING

Both numification (0+) and stringification ("") are overloaded to return the result of epoch. Numeric comparison and string comparison are overloaded based on those and fallback overloading is enabled.


AUTHORS


COPYRIGHT AND LICENSE

This software is Copyright (c) 2020 by Stefan G. and MongoDB, Inc.

This is free software, licensed under:

  The Apache License, Version 2.0, January 2004

Perl Diver brought to you by ScriptSolutions.com © 1997- 2026