コード例 #1
0
ファイル: TimeSpec.cs プロジェクト: mujing/rrd4net
 /**
  * Use this static method to resolve relative time references and obtain the corresponding
  * timestamps (seconds since epoch). Example:<p>
  * <pre>
  * TimeParser pStart = new TimeParser("now-1month"); // starting time
  * TimeParser pEnd = new TimeParser("start+1week");  // ending time
  * TimeSpec specStart = pStart.parse();
  * TimeSpec specEnd = pEnd.parse();
  * long[] ts = TimeSpec.getTimestamps(specStart, specEnd);
  * </pre>
  * @param spec1 Starting time specification
  * @param spec2 Ending time specification
  * @return array containing two timestamps (in seconds since epoch)
  */
 public static long[] getTimestamps(TimeSpec spec1, TimeSpec spec2)
 {
    DateTime[] gcs = getTimes(spec1, spec2);
    return new long[] {
                         Util.getTimestamp(gcs[0]), Util.getTimestamp(gcs[1])
                      };
 }
コード例 #2
0
ファイル: TimeParser.cs プロジェクト: mujing/rrd4net
 /**
  * Constructs TimeParser instance from the given input string.
  * @param dateString at-style time specification (read rrdfetch man page
  * for the complete explanation)
  */
 public TimeParser(String dateString)
 {
    scanner = new TimeScanner(dateString);
    spec = new TimeSpec(dateString);
 }
コード例 #3
0
ファイル: TimeSpec.cs プロジェクト: mujing/rrd4net
 /**
  * Use this static method to resolve relative time references and obtain the corresponding
  * Calendar objects. Example:<p>
  * <pre>
  * TimeParser pStart = new TimeParser("now-1month"); // starting time
  * TimeParser pEnd = new TimeParser("start+1week");  // ending time
  * TimeSpec specStart = pStart.parse();
  * TimeSpec specEnd = pEnd.parse();
  * GregorianCalendar[] gc = TimeSpec.getTimes(specStart, specEnd);
  * </pre>
  * @param spec1 Starting time specification
  * @param spec2 Ending time specification
  * @return Two element array containing Calendar objects
  */
 public static DateTime[] getTimes(TimeSpec spec1, TimeSpec spec2)
 {
    if (spec1.type == TYPE_START || spec2.type == TYPE_END)
    {
       throw new ArgumentException("Recursive time specifications not allowed");
    }
    spec1.context = spec2;
    spec2.context = spec1;
    return new[] {
                    spec1.getTime(),
                    spec2.getTime()
                 };
 }