3 This version of Now added 103040 bytes of text (code) and 488 bytes of
4 data to my smtp program vs. the old school C/Unix style code in the
5 version I'm using. Plus, it's dynamic memory for the string, etc. It
6 seems to just call the same strftime from libc anyhow.
10 ==32766== Conditional jump or move depends on uninitialised value(s)
11 ==32766== at 0x844FF22: __strftime_internal (strftime_l.c:543)
12 ==32766== by 0x8451FA5: strftime_l (strftime_l.c:459)
13 ==32766== by 0x7B81C88: std::__timepunct<char>::_M_put(char*, unsigned long,
14 char const*, tm const*) const (time_members.cc:47)
15 ==32766== by 0x7BD7621: std::time_put<char, std::ostreambuf_iterator<char,
16 std::char_traits<char> > >::do_put(std::ostreambuf_iterator<char,
17 std::char_traits<char> >, std::ios_base&, char, tm const*, char, char) const
18 (locale_facets_nonio.tcc:1343)
19 ==32766== by 0x7BD5BC6: std::time_put<char, std::ostreambuf_iterator<char,
20 std::char_traits<char> > >::put(std::ostreambuf_iterator<char,
21 std::char_traits<char> >, std::ios_base&, char, tm const*, char const*, char
22 const*) const (locale_facets_nonio.tcc:1302)
23 ==32766== by 0x415C71: RFC5321::Ctx::new_msg() (in
24 /z/home/gene/work/ghsmtp/smtp)
25 ==32766== by 0x4187A3: bool
26 tao::pegtl::internal::seq<tao::pegtl::sor<RFC5321::bogus_cmd_short,
27 RFC5321::data, RFC5321::quit, RFC5321::rset, RFC5321::noop, RFC5321::vrfy,
28 RFC5321::help, RFC5321::helo, RFC5321::ehlo, RFC5321::bdat, RFC5321::bdat_last,
29 RFC5321::starttls, RFC5321::rcpt_to, RFC5321::mail_from,
30 RFC5321::bogus_cmd_long, RFC5321::anything_else>,
31 tao::pegtl::discard>::match<(tao::pegtl::apply_mode)1,
32 (tao::pegtl::rewind_mode)1, RFC5321::action, tao::pegtl::normal,
33 tao::pegtl::istream_input<tao::pegtl::ascii::eol::crlf>,
34 RFC5321::Ctx&>(tao::pegtl::istream_input<tao::pegtl::ascii::eol::crlf>&,
35 RFC5321::Ctx&) (in /z/home/gene/work/ghsmtp/smtp)
36 ==32766== by 0x41092A: main (in /z/home/gene/work/ghsmtp/smtp)
41 // This on x86_64 using gcc version 7.1.1.
49 #include <glog/logging.h>
56 : v_
{std::chrono::system_clock::now()}
58 // RFC 5322 section 3.3 date-time.
59 date::format("%a, %d %b %Y %H:%M:%S %z",
60 date::make_zoned(date::current_zone(),
61 date::floor
<std::chrono::seconds
>(v_
)))}
63 CHECK_EQ(str_
.length(), 31) << str_
<< " is the wrong length";
68 return std::chrono::duration_cast
<std::chrono::seconds
>(
69 v_
.time_since_epoch())
74 return std::chrono::duration_cast
<std::chrono::microseconds
>(
75 v_
.time_since_epoch())
79 std::string
const& string() const { return str_
; }
81 bool operator==(Now
const& that
) const { return v_
== that
.v_
; }
82 bool operator!=(Now
const& that
) const { return !(*this == that
); }
85 std::chrono::time_point
<std::chrono::system_clock
> v_
;
88 friend std::ostream
& operator<<(std::ostream
& s
, Now
const& now
)