2012年7月21日土曜日

Set the 'bios' time of the virtual box.

When I posted my question there were 12 days left in September. what about next week, what about next month, ...? In short: I was hoping for something generic. Something like the following: 
CODE: SELECT ALL   EXPAND VIEW
vboxdate () {
   # Adjust VM BIOS time to a given date
   secs=$(date –date "$*" +%s)    # convert supplied date to secs, since 1970-01-01
   let secs-=$(date +%s)           # subtract the date NOW
   msecs=$(( $secs * 1000 ))       # convert to millis
   echo Adjusting time ${msecs}ms
   VBoxManage modifyvm Vista -biossystemtimeoffset ${msecs};
}
 
 


 

Here's a perl script I use. You may not have the Date::Manip module in your distribution, but you can get it from http://search.cpan.org/search?query=Date%3A%3AManip&mode=all 

CODE: SELECT ALL   EXPAND VIEW
#!/usr/bin/perl -w
use strict;
use Date::Manip;

my $start = join(' ', @ARGV);
my $sdate = ParseDate($start);
my $edate = ParseDate("now");
my $sepoch = UnixDate($sdate, "%s");
my $eepoch = UnixDate($edate, "%s");
my $msec = -1000 * ($eepoch - $sepoch);

print "Something like:\nVBoxManage modifyvm <name> -biossystemtimeoffset $msec\n";
 
 

0 件のコメント:

コメントを投稿