/**
  * Normalize the date and time to be in timezone Z.
  *
  * @param cc used to supply the implicit timezone, used when the value has no explicit timezone
  * @return in general, a new DateTimeValue in timezone Z, representing the same instant in time.
  *     Returns the original DateTimeValue if this is already in timezone Z.
  * @throws NoDynamicContextException if the implicit timezone is needed and is not available
  */
 public DateTimeValue normalize(XPathContext cc) throws NoDynamicContextException {
   if (hasTimezone()) {
     return (DateTimeValue) adjustTimezone(0);
   } else {
     DateTimeValue dt = (DateTimeValue) copyAsSubType(null);
     dt.setTimezoneInMinutes(cc.getImplicitTimezone());
     return (DateTimeValue) dt.adjustTimezone(0);
   }
 }
    // Rules from XML Schema Part 2
    public int compareTo(Object o) {
      if (o instanceof DateTimeComparable) {
        DateTimeValue dt0 = DateTimeValue.this;
        DateTimeValue dt1 = ((DateTimeComparable) o).asDateTimeValue();
        if (dt0.hasTimezone()) {
          if (dt1.hasTimezone()) {
            dt0 = (DateTimeValue) dt0.adjustTimezone(0);
            dt1 = (DateTimeValue) dt1.adjustTimezone(0);
            return dt0.compareTo(dt1);
          } else {
            DateTimeValue dt1max = (DateTimeValue) dt1.adjustTimezone(14 * 60);
            if (dt0.compareTo(dt1max) < 0) {
              return -1;
            }
            DateTimeValue dt1min = (DateTimeValue) dt1.adjustTimezone(-14 * 60);
            if (dt0.compareTo(dt1min) > 0) {
              return +1;
            }
            return INDETERMINATE_ORDERING;
          }
        } else {
          if (dt1.hasTimezone()) {
            DateTimeValue dt0min = (DateTimeValue) dt0.adjustTimezone(-14 * 60);
            if (dt0min.compareTo(dt1) < 0) {
              return -1;
            }
            DateTimeValue dt0max = (DateTimeValue) dt0.adjustTimezone(14 * 60);
            if (dt0max.compareTo(dt1) > 0) {
              return +1;
            }
            return INDETERMINATE_ORDERING;
          } else {
            dt0 = (DateTimeValue) dt0.adjustTimezone(0);
            dt1 = (DateTimeValue) dt1.adjustTimezone(0);
            return dt0.compareTo(dt1);
          }
        }

      } else {
        return INDETERMINATE_ORDERING;
      }
    }