~ubuntu-branches/ubuntu/quantal/virt-top/quantal

« back to all changes in this revision

Viewing changes to virt-top/virt_top_calendar2.ml

  • Committer: Package Import Robot
  • Author(s): Laurent Léonard
  • Date: 2011-08-15 23:19:06 UTC
  • mfrom: (3.1.4 sid)
  • Revision ID: package-import@ubuntu.com-20110815231906-rp38flx2z9jpx1gx
Tags: 1.0.6-1
* [7c3e6a1] Imported Upstream version 1.0.6
* [f0a771b] Redo patch
* [6629856] Bump Standards-Version to 3.9.2
* [930eafd] New patch 0002-Ensure-manpages-get-built-when-using-native-
  compiler.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
          Calendar.Period.make 0 0 0 hh mm ss
39
39
        ) else                          (* +seconds *)
40
40
          Calendar.Period.second (int_of_string period) in
41
 
      (* Add it as an offset from the current time. *)
 
41
      (* Add it as an offset from the current time.
 
42
       *
 
43
       * Note that the default for the Calendar library is to return
 
44
       * Calendar.now in the UTC time zone, which is in fact what we
 
45
       * need below.
 
46
       *)
42
47
      Calendar.add (Calendar.now ()) period
43
48
    ) else (
44
 
      if String.contains time '-' then  (* YYYY-MM-DD HH:MM:SS *)
45
 
        Printer.CalendarPrinter.from_string time
46
 
      else (                            (* HH:MM:SS *)
47
 
        let time = Printer.TimePrinter.from_string time in
48
 
        Calendar.create (Date.today ()) time
49
 
      )
 
49
      let cal =
 
50
        if String.contains time '-' then (* YYYY-MM-DD HH:MM:SS *)
 
51
          Printer.CalendarPrinter.from_string time
 
52
        else (                           (* HH:MM:SS *)
 
53
          let time = Printer.TimePrinter.from_string time in
 
54
          Calendar.create (Date.today ()) time
 
55
        ) in
 
56
      (* Assume the user has entered a local time.  Convert it to
 
57
       * UTC time zone which is what we need below.  (RHBZ#680344)
 
58
       *)
 
59
      Calendar.convert cal Time_Zone.Local Time_Zone.UTC
50
60
    ) in
51
61
 
52
 
  eprintf "end time: %s\n" (Printer.CalendarPrinter.to_string cal);
 
62
  eprintf "end time (UTC): %s\n" (Printer.CalendarPrinter.to_string cal);
53
63
 
54
64
  (* Convert to a time_t.  Note that we compare this against
55
65
   * Unix.gettimeofday in the main module, so this must be returned as