#1 CDateTime implementation

v 1.0
open
nobody
Core (1)
5
2009-04-19
2009-04-19
renqilin
No

This is an initial version of datetime class created by Asim. The code weren't tested under linux.

The patch file was created by inputing command:

svn diff > CDateTime.patch

under sandbox/cross_platform_test directory.

Discussion

  • renqilin
    renqilin
    2009-04-19

     
    Attachments
  • renqilin
    renqilin
    2009-04-19

    The code are neat. Here I have a few comments:

    1.
    DateTime.h, line 18: #include <ostream>
    line 27: std::ostream& operator<<(std::ostream& out, const DateTime& dt);

    I suggest that we avoid including any STL headers in public headers. Those headers not only makes the compilation slower and slower but also increase object file sizes. Moreover, using stl library across dll boundaries is a nightmare.

    If it is necessary to output CDateTime to iostream, I would suggest implementing this by providing the following two functions:

    void ToString(OUT AsciiString& str) const;
    void ToString(OUT UnicodeString& str) const;

    The two functions are quite similar to System.Object.ToString() in C#.

    2.
    I think the following functions are important for DateTime class:
    - copy-constructor
    - assignment operator (operator =)
    - less operator (operator <)
    - int Compare(const DateTime& rhs) const;

    A c++ class that implements those functions can be easily used in STL containers. We can also use DateTime as a key in std::map without writing any new code.