date class.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Prasad

    date class.

    Hi All,

    I want to perform some date calculations. Is there any standard class
    in the C++ which will help me?

    I want to perform operations like, difference between 2 date,
    incrementaing the date etc.

    I am working on SUSE 10 (LINUX kind of os). And using g++ and c++ for
    comilations.

    Thanks in advance.

    Thanks & regards,
    Prasad.

  • zqzhangster@gmail.com

    #2
    Re: date class.

    you can use boost

    Comment

    • kwikius

      #3
      Re: date class.


      Prasad wrote:[color=blue]
      > Hi All,
      >
      > I want to perform some date calculations. Is there any standard class
      > in the C++ which will help me?[/color]

      The boost date_time library is currently being discussed for inclusion
      in the next version of the C++ standard:



      To get it you will need to download and install the boost distro from

      [color=blue]
      > I want to perform operations like, difference between 2 date,
      > incrementaing the date etc.
      >
      > I am working on SUSE 10 (LINUX kind of os). And using g++ and c++ for
      > comilations.[/color]

      Boost keeps data on which of their libraries work with each compiler.
      See the links from theRegression Tests heading for date_time at
      http://www.boost.org. e.g:



      regards
      Andy Little

      Comment

      • Howard Hinnant

        #4
        Re: date class.

        In article <1148027972.556 427.246170@38g2 000cwa.googlegr oups.com>,
        "Prasad" <prasadjoshi_ao l@yahoo.co.in> wrote:
        [color=blue]
        > Hi All,
        >
        > I want to perform some date calculations. Is there any standard class
        > in the C++ which will help me?
        >
        > I want to perform operations like, difference between 2 date,
        > incrementaing the date etc.
        >
        > I am working on SUSE 10 (LINUX kind of os). And using g++ and c++ for
        > comilations.[/color]

        In addition to the boost suggestion (which is a good suggestion), here's
        a date class with a cute syntax:



        It allows a very intuitive and error-proof construction:

        date d = may/19/2006;

        Or if you want the 3rd Friday in May:

        date d = 3*fri/may/2006;

        -Howard

        Comment

        • Roland Pibinger

          #5
          Re: date class.

          On 19 May 2006 01:39:32 -0700, "Prasad" <prasadjoshi_ao l@yahoo.co.in>
          wrote:[color=blue]
          >I want to perform some date calculations. Is there any standard class
          >in the C++ which will help me?[/color]

          No
          [color=blue]
          >I want to perform operations like, difference between 2 date,
          >incrementain g the date etc.[/color]

          If you want a lightweigth date class (and don't want to introduce the
          complexity of Boost into your program) look for one of the freely
          available date classes like zDate and the 'Killer Date class'.

          Best wishes,
          Roland Pibinger

          Comment

          • Richard Herring

            #6
            Re: date class.

            In message
            <howard.hinna nt-C6A935.10320919 052006@syrcnyrd rs-02-ge0.nyroc.rr.co m>,
            Howard Hinnant <howard.hinnant @gmail.com> writes[color=blue]
            >In article <1148027972.556 427.246170@38g2 000cwa.googlegr oups.com>,
            > "Prasad" <prasadjoshi_ao l@yahoo.co.in> wrote:
            >[color=green]
            >> Hi All,
            >>
            >> I want to perform some date calculations. Is there any standard class
            >> in the C++ which will help me?
            >>
            >> I want to perform operations like, difference between 2 date,
            >> incrementaing the date etc.
            >>
            >> I am working on SUSE 10 (LINUX kind of os). And using g++ and c++ for
            >> comilations.[/color]
            >
            >In addition to the boost suggestion (which is a good suggestion), here's
            >a date class with a cute syntax:
            >
            >http://home.twcny.rr.com/hinnant/cpp...rian_date.html
            >
            >It allows a very intuitive and error-proof construction:
            >
            >date d = may/19/2006;[/color]

            Interesting and ingenious. But I think there might be an argument for
            _not_ using the locale to determine the default output format, but
            instead to use the unambiguous ISO standard format yyyy-mm-dd.

            (http://www.cl.cam.ac.uk/~mgk25/iso-time.html)

            There's no reason why it can't be more liberal in what it accepts for
            input, and maybe add a locale-dependent user-formatted output function
            as well.

            The default "C" locale's format is unfortunately horribly ambiguous. You
            may think 10/12/50 was in October, but I happen to know it was December,
            and if you live in Thailand it won't happen until next year. 1950-12-10
            is unambiguous, *and* as a bonus you can sort it lexicographical ly.
            [color=blue]
            >
            >Or if you want the 3rd Friday in May:
            >
            >date d = 3*fri/may/2006;
            >[/color]

            --
            Richard Herring

            Comment

            • Howard Hinnant

              #7
              Re: date class.

              In article <UwRrrNJ1UtdEFw TZ@baesystems.c om>,
              Richard Herring <junk@[127.0.0.1]> wrote:
              [color=blue]
              > Interesting and ingenious. But I think there might be an argument for
              > _not_ using the locale to determine the default output format, but
              > instead to use the unambiguous ISO standard format yyyy-mm-dd.[/color]

              Thanks. And agreed. I/O is its weak point. I basically just gave up
              (punted). The C++ locale system and I don't get along very well.

              -Howard

              Comment

              Working...