ID:165245
 
Well, I don't want to span your email Deadron so I figured I'd place this piece of code here. One thing I noticed about world.realtime, which is being used in the Calendar library, is that it takes a while for the seconds to update. This is because of what is mentioned in the Help guide about using world.realtime. If you change the _processTime function to use something more accurate like, world.timeofday, you fix the seconds problem, but now you have a date issue. I think I've come up with a solution, although I'm not 100% sure about this.

Inside of the process function:

   _processTime(raw_ticks, time_format)
// (...)

var/time_remaining = ticks_after_starting_time + (time_zone * hourTicks)

// This is new and allows us to have an accurate remaining time.
var/time_remainingAc = (world.timeofday - startingTimeOffset()) + (time_zone * hourTicks)


That was the first change, adding in the time_remainingAc variable. Here was the second change.

   var/daysIntoYear  = round(time_remaining / day_ticks) + 1
var/daysModulo = time_remainingAc % day_ticks
var/hours = round(daysModulo / hourTicks)
var/hoursModulo = daysModulo % hourTicks
var/minutes = round(hoursModulo / minuteTicks)
var/minutesModulo = hoursModulo % minuteTicks
var/seconds = round(minutesModulo / secondTicks)


In here you can see that the daysModulo variable is now using that new variable I created to display the accurate hour/minutes/seconds.

So far all of this seems to work fine for me in my implementation and I want to confirm if this is correct or if anyone can find something faulty in my code. Thanks.

var/BaseCamp/Calendar/game_calendar = new()

client
New()
DisplayTime()
..()

proc/DisplayTime()
spawn(10)
world << "The time is [game_calendar.CurrentTime()]."
DisplayTime()

Goten84 wrote:
Well, I don't want to span your email Deadron so I figured I'd place this piece of code here. One thing I noticed about world.realtime, which is being used in the Calendar library, is that it takes a while for the seconds to update. This is because of what is mentioned in the Help guide about using world.realtime. If you change the _processTime function to use something more accurate like, world.timeofday, you fix the seconds problem, but now you have a date issue.

Yeah we didn't have world.timeofday back when this library was created (six years ago -- sheesh).



   _processTime(raw_ticks, time_format)
// (...)

var/time_remaining = ticks_after_starting_time + (time_zone * hourTicks)

// This is new and allows us to have an accurate remaining time.
var/time_remainingAc = (world.timeofday - startingTimeOffset()) + (time_zone * hourTicks)


My concern about this approach is that ticks_after_starting_time could be larger than a day's worth of ticks, which would presumably have an undesirable effect. In your case, if this works for you, I'd say go for it. I won't be able to update the library until I have a chance to wrap my head around this stuff.

Also, unfortunately when I wrote this I wasn't taking a test-driven development approach yet, so it's harder for me to update. I oughta slap that guy who was me.

Meantime, unless this library is getting a lot of use, it's probably not worth it right now for me to put in the time. However, if people are using it, please let me know!