12 void Clock::set_rate(float s)
17 void Clock::set_current_time(const Time::TimeDelta &t)
22 void Clock::tick(const Time::TimeDelta &dt)
24 unsigned prev_minute = current_time/Time::min;
25 current_time += dt*rate;
26 if(current_time>=Time::day)
27 current_time -= Time::day;
28 unsigned minute = current_time/Time::min;
29 if(minute!=prev_minute)
33 void Clock::save(list<DataFile::Statement> &st) const
35 st.push_back((DataFile::Statement("rate"), rate));
36 st.push_back((DataFile::Statement("time"), current_time.raw()));
40 Clock::Loader::Loader(Clock &c):
41 DataFile::ObjectLoader<Clock>(c)
43 add("rate", &Clock::rate);
44 add("time", &Loader::time);
47 void Clock::Loader::time(Time::RawTime t)
49 obj.set_current_time(Time::TimeDelta(t));