Libraries‎ > ‎Somie‎ > ‎

Clock

BehaviourComposer: ignore everything before this.

Begin micro-behaviour:

Begin description:

Globals for reporting time within a model.

End description

Clock

Begin NetLogo code:

set the-minute the-minute + 1
if ticks > 0 [
if ticks mod 60 = 0 [ set the-minute 0 set the-hour the-hour + 1 ]
if ticks mod ( 60 * 24 ) = 0 [ set the-hour 0 set the-day the-day + 1 ]
if ticks mod ( 60 * 24 ) = 0 [ set the-weekday the-weekday + 1 ]
if ticks mod ( 60 * 24 * 7 ) = 0 [ set the-weekday 0 ]
if ticks mod ( 60 * 24 * 30 ) = 0 [ set the-month the-month + 1 ] ; all months aren't 30 days!
if ticks mod ( 60 * 24 * 30 * 12 ) = 0 [ set the-month 0 set the-day 0 set the-year the-year + 1 ]
]
set the-weekday-text [ "Lundi" "Mardi" "Mecredi" "Jeudi" "Vendredi" "Samedi" "Dimanche" ]
set the-weekday-monitor item the-weekday the-weekday-text
set the-month-text [ "Jan" "Feb" "Mar" "Avr" "Mai" "Jun" "Jul" "Aout" "Set" "Oct" "Nov" "Dec" ]
set the-month-monitor item the-month the-month-text
set the-time-date 
( word the-hour ":" the-minute  "   " the-month-monitor "-" the-day "-" the-year "   " the-weekday-monitor )

End NetLogo code

Variants

How this works

Related micro-behaviours

History

BehaviourComposer: ignore everything after this.

Comments