<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 02:53:48 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>MongoDB Jira</title>
    <link>https://jira.mongodb.org</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>9.7.1</version>
        <build-number>970001</build-number>
        <build-date>13-04-2023</build-date>
    </build-info>


<item>
            <title>[SERVER-350] Append a date as std::time_t to BSONObj from a stream </title>
                <link>https://jira.mongodb.org/browse/SERVER-350</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;A small enhancement just to be able to do:&lt;/p&gt;

&lt;p&gt;BSONObj o = BSON(&quot;date&quot; &amp;lt;&amp;lt; std::time(0));&lt;/p&gt;

&lt;p&gt;Currently, we have to manipulate BSONObjBuilder::appendDate() in order to append a date from a std::time_t.&lt;br/&gt;
There is no append() overload which takes an unsigned long long (in the case we would like to cast std::time_t)&lt;/p&gt;


&lt;p&gt;diff --git a/db/jsobj.h b/db/jsobj.h&lt;br/&gt;
index 3afc916..8783f5e 100644&lt;br/&gt;
&amp;#8212; a/db/jsobj.h&lt;br/&gt;
+++ b/db/jsobj.h&lt;br/&gt;
@@ -1167,6 +1167,13 @@ namespace mongo &lt;/p&gt;
{
             b.append(n);
             return *this;
         }
&lt;p&gt;+        &lt;br/&gt;
+        /** Append a date from a std::time_t */&lt;br/&gt;
+        void append(const char *fieldName, std::time_t dt) &lt;/p&gt;
{ 
+            b.append((char) Date);
+            b.append(fieldName);
+            b.append(dt*1000);
+        }

&lt;p&gt;         /** Append a BSON Object ID (OID type). */&lt;br/&gt;
         void appendOID(const char *fieldName, OID *oid = 0 , bool generateIfBlank = false ) {&lt;/p&gt;</description>
                <environment></environment>
        <key id="10727">SERVER-350</key>
            <summary>Append a date as std::time_t to BSONObj from a stream </summary>
                <type id="2" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14711&amp;avatarType=issuetype">New Feature</type>
                                            <priority id="5" iconUrl="https://jira.mongodb.org/images/icons/priorities/trivial.svg">Trivial - P5</priority>
                        <status id="6" iconUrl="https://jira.mongodb.org/images/icons/statuses/closed.png" description="The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.">Closed</status>
                    <statusCategory id="3" key="done" colorName="success"/>
                                    <resolution id="9">Done</resolution>
                                        <assignee username="mathias@mongodb.com">Mathias Stearn</assignee>
                                    <reporter username="metagoto">metagoto</reporter>
                        <labels>
                    </labels>
                <created>Fri, 9 Oct 2009 18:30:31 +0000</created>
                <updated>Tue, 12 Jul 2016 00:29:58 +0000</updated>
                            <resolved>Thu, 15 Oct 2009 14:00:23 +0000</resolved>
                                                    <fixVersion>1.1.2</fixVersion>
                                    <component>Internal Client</component>
                    <component>Usability</component>
                                        <votes>0</votes>
                                    <watches>3</watches>
                                                                                                                <comments>
                            <comment id="10923" author="eliot" created="Fri, 16 Oct 2009 15:33:21 +0000"  >&lt;p&gt;release 10/16/2009&lt;/p&gt;</comment>
                            <comment id="10904" author="metagoto" created="Fri, 16 Oct 2009 12:27:11 +0000"  >&lt;p&gt;1), 2) Yes, you&apos;re right.&lt;/p&gt;

&lt;p&gt;DATENOW is OK for me. A &apos;now date&apos; from a stream is very useful. Thanks.&lt;br/&gt;
Specific dates still can be appended with BSONObjBuilder::appendDate() so TIMET() and DATE() are fine but not top priority as far as I&apos;m concerned.&lt;/p&gt;

</comment>
                            <comment id="10903" author="redbeard0531" created="Fri, 16 Oct 2009 12:10:44 +0000"  >&lt;p&gt;two problems with that:&lt;br/&gt;
1) It would force users to use 32 bit time_t&lt;br/&gt;
2) It still wouldn&apos;t make time_t a distinct type for overloading purposes&lt;/p&gt;

&lt;p&gt;I forgot to mention that we added a DATENOW constant (non-macro) so you can do:&lt;br/&gt;
BSONObj o = BSON(&quot;created&quot; &amp;lt;&amp;lt; DATENOW);&lt;/p&gt;

&lt;p&gt;if you really need to specify specific dates in the BSON macro I can add something like this:&lt;br/&gt;
BSON(&quot;somedate&quot; &amp;lt;&amp;lt; TIMET(sec_since_epoch))&lt;br/&gt;
BSON(&quot;somedate&quot; &amp;lt;&amp;lt; DATE(milisecs_since_epoch))&lt;/p&gt;</comment>
                            <comment id="10898" author="metagoto" created="Fri, 16 Oct 2009 00:51:50 +0000"  >&lt;p&gt;Did you consider _USE_32BIT_TIME_T ?&lt;br/&gt;
&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/323b6b3k.aspx&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://msdn.microsoft.com/en-us/library/323b6b3k.aspx&lt;/a&gt;&lt;br/&gt;
Sorry, I can&apos;t test on a Windows machine currently&lt;/p&gt;</comment>
                            <comment id="10896" author="redbeard0531" created="Thu, 15 Oct 2009 17:31:36 +0000"  >&lt;p&gt;Had to add a new appendTimeT() method because MSVC doesn&apos;t consider time_t to be distinct from __int64.&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>5.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Thu, 15 Oct 2009 17:31:36 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        14 years, 18 weeks, 5 days ago
    
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_18254" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Dependencies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue><![CDATA[]]></customfieldvalue>


                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_10057" key="com.atlassian.jira.toolkit:lastusercommented">
                        <customfieldname>Last comment by Customer</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>true</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_10056" key="com.atlassian.jira.toolkit:lastupdaterorcommenter">
                        <customfieldname>Last commenter</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>ramon.fernandez@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            14 years, 18 weeks, 5 days ago
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                    <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>eliot</customfieldvalue>
            <customfieldvalue>mathias@mongodb.com</customfieldvalue>
            <customfieldvalue>metagoto</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hrpvhb:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hrivvj:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>23817</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_23361" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Requested By</customfieldname>
                        <customfieldvalues>
                                

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_10053" key="com.atlassian.jira.ext.charting:timeinstatus">
                        <customfieldname>Time In Status</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_22870" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Triagers</customfieldname>
                        <customfieldvalues>
                                

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_14350" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>serverRank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|ht0l07:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                    </customfields>
    </item>
</channel>
</rss>