public inbox for mauve-discuss@sourceware.org
 help / color / mirror / Atom feed
* RE: java.util.Date mess
@ 2004-10-12  9:35 Jeroen Frijters
  2004-10-12  9:41 ` Andrew Haley
  2004-10-12  9:41 ` Michael Koch
  0 siblings, 2 replies; 3+ messages in thread
From: Jeroen Frijters @ 2004-10-12  9:35 UTC (permalink / raw)
  To: Michael Koch, classpath; +Cc: Mauve Discuss

[-- Attachment #1: Type: text/plain, Size: 940 bytes --]

Michael Koch wrote:
> On Monday 11 October 2004 15:39, Jeroen Frijters wrote:
> > I have some code that depends on unspecified behavior of
> > java.util.Date. In the Sun JDK if you pass out of range parameters
> > to the Date constructors that take year, month, date, etc. it will
> > automatically convert to a valid date (for example, new Date(104,
> > 8, 41) is Oct 11, 2004.)
> >
> > I have a rather lame patch that addresses this (see below), would
> > anyone object to this?
> 
> Are there mauve test that confirm that this breaks nothing ?

I made a new Mauve test (attached) that works better with my patch
(after I fixed one error in my patch and fixed an additional Date bug),
but it still fails on three tests. One is due to a bug in
GregorianCalendar and I haven't investigated the other two.

Is the attached test OK to commit? Do I need to modify any other Mauve
files to add the test?

Regards,
Jeroen

[-- Attachment #2: range.java --]
[-- Type: application/octet-stream, Size: 2052 bytes --]

// Tags: JDK1.0

// Copyright (C) 2004 Free Software Foundation, Inc.
// Contributed by Jeroen Frijters <jeroen@frijters.net>.

// This file is part of Mauve.

// Mauve is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2, or (at your option)
// any later version.

// Mauve is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Mauve; see the file COPYING.  If not, write to
// the Free Software Foundation, 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.

package gnu.testlet.java.util.Date;

import gnu.testlet.Testlet;
import gnu.testlet.TestHarness;
import java.util.Date;

public class range implements Testlet
{
  private TestHarness harness;

  public void test (TestHarness harness)
  {
    this.harness = harness;

    check(70, 0, 1, 0, 0, 0, 0);
    check(104, 9, 12, 0, 0, 0, 1097539200000L);
    check(104, 9, 12, 0, 0, 0, 1097539200000L);
    check(104, 9, 12, 12, 34, 0, 1097584440000L);
    check(104, 9, 12, 12, 34, 56, 1097584496000L);
    check(104, -1, 0, 0, 0, 0, 1070150400000L);
    check(104, 99, 99, 99, 99, 99, 1342068039000L);
    check(104, 999, 999, 999, 999, 999, 3785583171704L);
    check(104, -1, -1, -1, -1, -1, 1070060339000L);
    check(104, -999, -999, -999, -999, -999, -1640011971704L);
  }

  private void check(int year, int month, int day, int hours, int mins, int secs, long l)
  {
    try
      {
        Date d = new Date(year, month, day, hours, mins, secs);
        harness.check(d.getTime() - d.getTimezoneOffset() * 60 * 1000 == l);
      }
    catch (Throwable t)
      {
        harness.debug(t);
        harness.check(false);
      }
  }
}

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: java.util.Date mess
  2004-10-12  9:35 java.util.Date mess Jeroen Frijters
@ 2004-10-12  9:41 ` Andrew Haley
  2004-10-12  9:41 ` Michael Koch
  1 sibling, 0 replies; 3+ messages in thread
From: Andrew Haley @ 2004-10-12  9:41 UTC (permalink / raw)
  To: classpath, Mauve Discuss

A modest proposal: could those people attaching files please give them
a content-type of "text/plain" rather than "application/binary"?
They'd still be transmitted faithfully, bus mailers could display them
inline.

Thanks,
Andrew.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: java.util.Date mess
  2004-10-12  9:35 java.util.Date mess Jeroen Frijters
  2004-10-12  9:41 ` Andrew Haley
@ 2004-10-12  9:41 ` Michael Koch
  1 sibling, 0 replies; 3+ messages in thread
From: Michael Koch @ 2004-10-12  9:41 UTC (permalink / raw)
  To: Jeroen Frijters; +Cc: classpath, Mauve Discuss

On Tuesday 12 October 2004 11:35, Jeroen Frijters wrote:
> Michael Koch wrote:
> > On Monday 11 October 2004 15:39, Jeroen Frijters wrote:
> > > I have some code that depends on unspecified behavior of
> > > java.util.Date. In the Sun JDK if you pass out of range
> > > parameters to the Date constructors that take year, month,
> > > date, etc. it will automatically convert to a valid date (for
> > > example, new Date(104, 8, 41) is Oct 11, 2004.)
> > >
> > > I have a rather lame patch that addresses this (see below),
> > > would anyone object to this?
> >
> > Are there mauve test that confirm that this breaks nothing ?
>
> I made a new Mauve test (attached) that works better with my patch
> (after I fixed one error in my patch and fixed an additional Date
> bug), but it still fails on three tests. One is due to a bug in
> GregorianCalendar and I haven't investigated the other two.
>
> Is the attached test OK to commit? Do I need to modify any other
> Mauve files to add the test?

Just add the file with a proper ChangeLog entry and be done. Thats all 
you need to do. Thanks for the testcase.


Michael

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-10-12  9:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-12  9:35 java.util.Date mess Jeroen Frijters
2004-10-12  9:41 ` Andrew Haley
2004-10-12  9:41 ` Michael Koch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).