// Path: src/main/java/com/mdimension/jchronic/utils/Span.java
// public class Span extends Range {
// 
//   public Span(Calendar begin, int field, long amount) {
//     this(begin, Time.cloneAndAdd(begin, field, amount));
//   }
// 
//   public Span(Calendar begin, Calendar end) {
//     this(begin.getTimeInMillis() / 1000, end.getTimeInMillis() / 1000);
//   }
// 
//   public Span(long begin, long end) {
//     super(begin, end);
//   }
// 
//   public Calendar getBeginCalendar() {
//     Calendar cal = Calendar.getInstance();
//     cal.setTimeInMillis(getBegin() * 1000);
//     return cal;
//   }
// 
//   public Calendar getEndCalendar() {
//     Calendar cal = Calendar.getInstance();
//     cal.setTimeInMillis(getEnd() * 1000);
//     return cal;
//   }
// 
//   /**
//    * Add a number of seconds to this span, returning the 
//    * resulting Span
//    */
//   public Span add(long seconds) {
//     return new Span(getBegin() + seconds, getEnd() + seconds);
//   }
// 
//   /**
//    * Subtract a number of seconds to this span, returning the 
//    * resulting Span
//    */
//   public Span subtract(long seconds) {
//     return add(-seconds);
//   }
// 
//   @Override
//   public String toString() {
//     return "(" + DateFormat.getDateTimeInstance().format(getBeginCalendar().getTime()) + ".." + DateFormat.getDateTimeInstance().format(getEndCalendar().getTime()) + ")";
//   }
// }
// 
// Path: src/main/java/com/mdimension/jchronic/utils/Time.java
// public class Time {
//   public static Calendar construct(int year, int month) {
//     if (year <= 1900) {
//       throw new IllegalArgumentException("Illegal year '" + year + "'");
//     }
//     Calendar cal = Calendar.getInstance();
//     cal.clear();
//     cal.set(Calendar.YEAR, year);
//     cal.set(Calendar.MONTH, month - 1);
//     return cal;
//   }
// 
//   public static Calendar construct(int year, int month, int day) {
//     Calendar cal = Time.construct(year, month);
//     cal.set(Calendar.DAY_OF_MONTH, day);
//     return cal;
//   }
// 
//   public static Calendar construct(int year, int month, int day, int hour) {
//     Calendar cal = Time.construct(year, month, day);
//     cal.set(Calendar.HOUR_OF_DAY, hour);
//     return cal;
//   }
// 
//   public static Calendar construct(int year, int month, int day, int hour, int minute) {
//     Calendar cal = Time.construct(year, month, day, hour);
//     cal.set(Calendar.MINUTE, minute);
//     return cal;
//   }
// 
//   public static Calendar construct(int year, int month, int day, int hour, int minute, int second) {
//     Calendar cal = Time.construct(year, month, day, hour, minute);
//     cal.set(Calendar.SECOND, second);
//     return cal;
//   }
// 
//   public static Calendar construct(int year, int month, int day, int hour, int minute, int second, int millisecond) {
//     Calendar cal = Time.construct(year, month, day, hour, minute, second);
//     cal.set(Calendar.MILLISECOND, millisecond);
//     return cal;
//   }
// 
//   public static Calendar y(Calendar basis) {
//     Calendar clone = Calendar.getInstance();
//     clone.clear();
//     clone.set(Calendar.YEAR, basis.get(Calendar.YEAR));
//     return clone;
//   }
// 
//   public static Calendar yJan1(Calendar basis) {
//     Calendar clone = Time.y(basis, 1, 1);
//     return clone;
//   }
// 
//   public static Calendar y(Calendar basis, int month) {
//     Calendar clone = Time.y(basis);
//     clone.set(Calendar.MONTH, month - 1);
//     return clone;
//   }
// 
//   public static Calendar y(Calendar basis, int month, int day) {
//     Calendar clone = Time.y(basis, month);
//     clone.set(Calendar.DAY_OF_MONTH, day);
//     return clone;
//   }
// 
//   public static Calendar ym(Calendar basis) {
//     Calendar clone = Time.y(basis);
//     clone.set(Calendar.MONTH, basis.get(Calendar.MONTH));
//     return clone;
//   }
// 
//   public static Calendar ymd(Calendar basis) {
//     Calendar clone = Time.ym(basis);
//     clone.set(Calendar.DAY_OF_MONTH, basis.get(Calendar.DAY_OF_MONTH));
//     return clone;
//   }
// 
//   public static Calendar ymdh(Calendar basis) {
//     Calendar clone = Time.ymd(basis);
//     clone.set(Calendar.HOUR_OF_DAY, basis.get(Calendar.HOUR_OF_DAY));
//     return clone;
//   }
// 
//   public static Calendar ymdhm(Calendar basis) {
//     Calendar clone = Time.ymdh(basis);
//     clone.set(Calendar.MINUTE, basis.get(Calendar.MINUTE));
//     return clone;
//   }
// 
//   public static Calendar cloneAndAdd(Calendar basis, int field, long amount) {
//     Calendar next = (Calendar) basis.clone();
//     next.add(field, (int) amount);
//     return next;
//   }
// }


import java.util.Calendar;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import com.mdimension.jchronic.utils.Span;
import com.mdimension.jchronic.utils.Time;
package com.mdimension.jchronic;




@RunWith(JUnit4.class)
public class SpanTestCase {
  private Calendar _now;

  @Before
  public void setUp() throws Exception {
    _now = Time.construct(2006, 8, 16, 14, 0, 0, 0);
  }

  @Test
  public void testSpanWidth() {
    Span span = new Span(Time.construct(2006, 8, 16, 0), Time.construct(2006, 8, 17, 0));
    Assert.assertEquals(60 * 60 * 24, span.getWidth());
  }

  @Test
  public void testSpanMath() {
    Span span = new Span(1, 2);
    Assert.assertEquals(2, span.add(1).getBegin());
// Path: src/main/java/com/mdimension/jchronic/utils/Span.java
// public class Span extends Range {
// 
//   public Span(Calendar begin, int field, long amount) {
//     this(begin, Time.cloneAndAdd(begin, field, amount));
//   }
// 
//   public Span(Calendar begin, Calendar end) {
//     this(begin.getTimeInMillis() / 1000, end.getTimeInMillis() / 1000);
//   }
// 
//   public Span(long begin, long end) {
//     super(begin, end);
//   }
// 
//   public Calendar getBeginCalendar() {
//     Calendar cal = Calendar.getInstance();
//     cal.setTimeInMillis(getBegin() * 1000);
//     return cal;
//   }
// 
//   public Calendar getEndCalendar() {
//     Calendar cal = Calendar.getInstance();
//     cal.setTimeInMillis(getEnd() * 1000);
//     return cal;
//   }
// 
//   /**
//    * Add a number of seconds to this span, returning the 
//    * resulting Span
//    */
//   public Span add(long seconds) {
//     return new Span(getBegin() + seconds, getEnd() + seconds);
//   }
// 
//   /**
//    * Subtract a number of seconds to this span, returning the 
//    * resulting Span
//    */
//   public Span subtract(long seconds) {
//     return add(-seconds);
//   }
// 
//   @Override
//   public String toString() {
//     return "(" + DateFormat.getDateTimeInstance().format(getBeginCalendar().getTime()) + ".." + DateFormat.getDateTimeInstance().format(getEndCalendar().getTime()) + ")";
//   }
// }
// 
// Path: src/main/java/com/mdimension/jchronic/utils/Time.java
// public class Time {
//   public static Calendar construct(int year, int month) {
//     if (year <= 1900) {
//       throw new IllegalArgumentException("Illegal year '" + year + "'");
//     }
//     Calendar cal = Calendar.getInstance();
//     cal.clear();
//     cal.set(Calendar.YEAR, year);
//     cal.set(Calendar.MONTH, month - 1);
//     return cal;
//   }
// 
//   public static Calendar construct(int year, int month, int day) {
//     Calendar cal = Time.construct(year, month);
//     cal.set(Calendar.DAY_OF_MONTH, day);
//     return cal;
//   }
// 
//   public static Calendar construct(int year, int month, int day, int hour) {
//     Calendar cal = Time.construct(year, month, day);
//     cal.set(Calendar.HOUR_OF_DAY, hour);
//     return cal;
//   }
// 
//   public static Calendar construct(int year, int month, int day, int hour, int minute) {
//     Calendar cal = Time.construct(year, month, day, hour);
//     cal.set(Calendar.MINUTE, minute);
//     return cal;
//   }
// 
//   public static Calendar construct(int year, int month, int day, int hour, int minute, int second) {
//     Calendar cal = Time.construct(year, month, day, hour, minute);
//     cal.set(Calendar.SECOND, second);
//     return cal;
//   }
// 
//   public static Calendar construct(int year, int month, int day, int hour, int minute, int second, int millisecond) {
//     Calendar cal = Time.construct(year, month, day, hour, minute, second);
//     cal.set(Calendar.MILLISECOND, millisecond);
//     return cal;
//   }
// 
//   public static Calendar y(Calendar basis) {
//     Calendar clone = Calendar.getInstance();
//     clone.clear();
//     clone.set(Calendar.YEAR, basis.get(Calendar.YEAR));
//     return clone;
//   }
// 
//   public static Calendar yJan1(Calendar basis) {
//     Calendar clone = Time.y(basis, 1, 1);
//     return clone;
//   }
// 
//   public static Calendar y(Calendar basis, int month) {
//     Calendar clone = Time.y(basis);
//     clone.set(Calendar.MONTH, month - 1);
//     return clone;
//   }
// 
//   public static Calendar y(Calendar basis, int month, int day) {
//     Calendar clone = Time.y(basis, month);
//     clone.set(Calendar.DAY_OF_MONTH, day);
//     return clone;
//   }
// 
//   public static Calendar ym(Calendar basis) {
//     Calendar clone = Time.y(basis);
//     clone.set(Calendar.MONTH, basis.get(Calendar.MONTH));
//     return clone;
//   }
// 
//   public static Calendar ymd(Calendar basis) {
//     Calendar clone = Time.ym(basis);
//     clone.set(Calendar.DAY_OF_MONTH, basis.get(Calendar.DAY_OF_MONTH));
//     return clone;
//   }
// 
//   public static Calendar ymdh(Calendar basis) {
//     Calendar clone = Time.ymd(basis);
//     clone.set(Calendar.HOUR_OF_DAY, basis.get(Calendar.HOUR_OF_DAY));
//     return clone;
//   }
// 
//   public static Calendar ymdhm(Calendar basis) {
//     Calendar clone = Time.ymdh(basis);
//     clone.set(Calendar.MINUTE, basis.get(Calendar.MINUTE));
//     return clone;
//   }
// 
//   public static Calendar cloneAndAdd(Calendar basis, int field, long amount) {
//     Calendar next = (Calendar) basis.clone();
//     next.add(field, (int) amount);
//     return next;
//   }
// }


// Path: src/test/java/com/mdimension/jchronic/SpanTestCase.java
import java.util.Calendar;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import com.mdimension.jchronic.utils.Span;
import com.mdimension.jchronic.utils.Time;

package com.mdimension.jchronic;




@RunWith(JUnit4.class)
public class SpanTestCase {
  private Calendar _now;

  @Before
  public void setUp() throws Exception {
    _now = Time.construct(2006, 8, 16, 14, 0, 0, 0);
  }

  @Test
  public void testSpanWidth() {
    Span span = new Span(Time.construct(2006, 8, 16, 0), Time.construct(2006, 8, 17, 0));
    Assert.assertEquals(60 * 60 * 24, span.getWidth());
  }

  @Test
  public void testSpanMath() {
    Span span = new Span(1, 2);
    Assert.assertEquals(2, span.add(1).getBegin());
    Assert.assertEquals(3, span.add(1).getEnd());