1BSON::Time(3)         User Contributed Perl Documentation        BSON::Time(3)
2
3
4

NAME

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

VERSION

9       version v1.12.2
10

SYNOPSIS

12           use BSON::Types ':all';
13
14           bson_time();        # now
15           bson_time( $secs ); # floating point seconds since epoch
16

DESCRIPTION

18       This module provides a BSON type wrapper for a 64-bit date-time value
19       in the form of milliseconds since the Unix epoch (UTC only).
20
21       On a Perl without 64-bit integer support, the value must be a
22       Math::BigInt object.
23

ATTRIBUTES

25   value
26       A integer representing milliseconds since the Unix epoch.  The default
27       is 0.
28

METHODS

30   epoch
31       Returns the number of seconds since the epoch (i.e. a floating-point
32       value).
33
34   as_iso8601
35       Returns the "value" as an ISO-8601 formatted string of the form
36       "YYYY-MM-DDThh:mm:ss.sssZ".  The fractional seconds will be omitted if
37       they are zero.
38
39   as_datetime
40       Loads DateTime and returns the "value" as a DateTime object.
41
42   as_datetime_tiny
43       Loads DateTime::Tiny and returns the "value" as a DateTime::Tiny
44       object.
45
46   as_mango_time
47       Loads Mango::BSON::Time and returns the "value" as a Mango::BSON::Time
48       object.
49
50   as_time_moment
51       Loads Time::Moment and returns the "value" as a Time::Moment object.
52
53   TO_JSON
54       Returns a string formatted by "as_iso8601".
55
56       If the "BSON_EXTJSON" option is true, it will instead be compatible
57       with MongoDB's extended JSON
58       <https://github.com/mongodb/specifications/blob/master/source/extended-
59       json.rst> format, which represents it as a document as follows:
60
61       If the "BSON_EXTJSON" environment variable is true and the
62       "BSON_EXTJSON_RELAXED" environment variable is false, returns a hashref
63       compatible with MongoDB's extended JSON
64       <https://github.com/mongodb/specifications/blob/master/source/extended-
65       json.rst> format, which represents it as a document as follows:
66
67           {"$date" : { "$numberLong": "22337203685477580" } }
68
69       If the "BSON_EXTJSON" and "BSON_EXTJSON_RELAXED" environment variables
70       are both true, then it will return a hashref with an ISO-8601 string
71       for dates after the Unix epoch and before the year 10,000 and a
72       $numberLong style value otherwise.
73
74           {"$date" : "2012-12-24T12:15:30.500Z"}
75           {"$date" : { "$numberLong": "-10000000" } }
76

OVERLOADING

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

AUTHORS

83       •   David Golden <david@mongodb.com>
84
85       •   Stefan G. <minimalist@lavabit.com>
86
88       This software is Copyright (c) 2020 by Stefan G. and MongoDB, Inc.
89
90       This is free software, licensed under:
91
92         The Apache License, Version 2.0, January 2004
93
94
95
96perl v5.36.0                      2022-07-22                     BSON::Time(3)
Impressum