01: /*
02: ** Java cvs client library package.
03: ** Copyright (c) 1997-2002 by Timothy Gerard Endres
04: **
05: ** This program is free software.
06: **
07: ** You may redistribute it and/or modify it under the terms of the GNU
08: ** Library General Public License (LGPL) as published by the Free Software
09: ** Foundation.
10: **
11: ** Version 2 of the license should be included with this distribution in
12: ** the file LICENSE.txt, as well as License.html. If the license is not
13: ** included with this distribution, you may find a copy at the FSF web
14: ** site at 'www.gnu.org' or 'www.fsf.org', or you may write to the Free
15: ** Software Foundation at 59 Temple Place - Suite 330, Boston, MA 02111 USA.
16: **
17: ** THIS SOFTWARE IS PROVIDED AS-IS WITHOUT WARRANTY OF ANY KIND,
18: ** NOT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY. THE AUTHOR
19: ** OF THIS SOFTWARE, ASSUMES _NO_ RESPONSIBILITY FOR ANY
20: ** CONSEQUENCE RESULTING FROM THE USE, MODIFICATION, OR
21: ** REDISTRIBUTION OF THIS SOFTWARE.
22: **
23: */
24:
25: package com.ice.cvsc;
26:
27: import java.lang.*;
28: import java.util.*;
29:
30: /**
31: * The CVSTimestamp class is a subclass of Date, specifically
32: * designed to be used as the time stamp of CVS entries. This
33: * class allows us to display the timestamps of CVS Entries,
34: * as well as determine when files have been updated.
35: *
36: * @version $Revision: 2.6 $
37: * @author Timothy Gerard Endres, <a href="mailto:time@ice.com">time@ice.com</a>.
38: * @see CVSTimestampFormat
39: */
40:
41: public class CVSTimestamp extends Date implements Cloneable {
42: static public final String RCS_ID = "$Id: CVSTimestamp.java,v 2.6 2003/07/27 01:08:32 time Exp $";
43: static public final String RCS_REV = "$Revision: 2.6 $";
44:
45: public CVSTimestamp() {
46: super ();
47: }
48:
49: public CVSTimestamp(long msSinceEpoch) {
50: super (msSinceEpoch);
51: }
52:
53: public CVSTimestamp(Date date) {
54: super (date.getTime());
55: }
56:
57: /**
58: * Determines if this timestamp is considered equivalent to
59: * the time represented by the parameter we are passed. Note
60: * that we allow up to, but not including, one second of time
61: * difference, since Java allows millisecond time resolution
62: * while CVS stores second resolution timestamps. Further, we
63: * allow the resolution difference on either side of the second
64: * because we can not be sure of the rounding.
65: *
66: */
67: public boolean equalsTime(long time) {
68: return ((this .getTime() > time) ? ((this .getTime() - time) < 1000)
69: : ((time - this .getTime()) < 1000));
70: }
71:
72: /**
73: * Determines if this timestamp is considered equivalent to
74: * the time represented by another timestamp. Note
75: * that we allow up to, but not including, one second of time
76: * difference, since Java allows millisecond time resolution
77: * while CVS stores second resolution timestamps. Further, we
78: * allow the resolution difference on either side of the second
79: * because we can not be sure of the rounding.
80: */
81: public boolean equalsTimestamp(CVSTimestamp stamp) {
82: return ((this .getTime() > stamp.getTime()) ? ((this .getTime() - stamp
83: .getTime()) < 1000)
84: : ((stamp.getTime() - this .getTime()) < 1000));
85: }
86:
87: }
|