Am I asking too much from datetime?

Discussion in 'Python' started by thehaas, Jun 1, 2004.

  1. thehaas

    thehaas Guest

    Hash: SHA1

    I'm trying to use the datetime module. The following seems to work
    any day except the first day of the month:
    Traceback (most recent call last):
    File "<stdin>", line 1, in ?
    ValueError: day is out of range for month

    In other languages (specifically Java, but I'm sure these are others),
    this would come out as "2004-05-31".

    Is this is a bug, or outside of the functionality of datetime?

    - --
    Mike Hostetler
    Version: GnuPG v1.2.4 (GNU/Linux)

    -----END PGP SIGNATURE-----
    thehaas, Jun 1, 2004
    1. Advertisements

  2. thehaas

    Yermat Guest

    Of course it does not work !
    0 is not a valid day...
    You should do something like:
    Yermat, Jun 1, 2004
    1. Advertisements

  3. yesterday =, today.month,
    Try writing it like this:

    Brian Quinlan, Jun 1, 2004
  4. thehaas

    thehaas Guest

    Except that it *does* work in other languages . . . that was part of
    my point. Here's a sample from some working Java code:

    // this works in January!
    Calendar now = Calendar.getInstance();
    Calendar lastmonth = Calendar.getInstance();
    Got it. Cool -- thanks.
    thehaas, Jun 1, 2004
  5. thehaas

    Yermat Guest

    I understand your felling but I really believe it SHOULD not go that way
    in other language... And so understand the python library point of view
    to be the better one.

    Anyway that's another debate ;-)
    Yermat, Jun 1, 2004
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.