#!/usr/bin/perl
# Access a field, updating the heartbeat.
#use Mooix::Thing;
#use Mooix::Root;
run sub {
	my $this=shift;
	
	if (@_) {
		$this->_timeoffset(@_);

		# Unregister old from heartbeat. Don't restart heartbeat,
		# since it will be restarted by the subsequent add anyway.
		$Mooix::Root->system->heartbeat->remove(
			item => $this->item,
			noupdate => 1,
		);
		
		# Register with the heartbeat.
		$this->item($Mooix::Root->system->heartbeat->add(
			object => $this,
			method => "chime",
			interval => 60 * 60, # each hour
			startdate => -1 * $this->_timeoffset, # on the hour
		));
	}
	
	return $this->_timeoffset;
}
