Beginners Interactive NetLogo Dictionary (BIND)
Farsi / Persian
NetLogo User Community Models
# TIME EXTENSION EXAMPLE: LOGOTIMES
## WHAT IS IT?
This is a simple demonstration of how to use NetLogo's time extension to represent real dates and times in a model. It shows how to create, manipulate, and output the "Logotime" variable type provided by the time extension. The NetLogo User Manual's section on the time extension provides much more detail and more examples.
A Logotime variable can hold one of three kinds of time values: a DATETIME--a date and time, with precision down to milliseconds; a DATE--a day specified by year, month, and date, but with no sub-daily information; and a DAY--a day of the year without specifying which year (e.g., April 15). This model uses only the DATETIME type.
This "model" simply ticks through a specified amount of time and reports the time at each tick in a variety of units.
## HOW IT WORKS
Comments in the Code tab explain how the model works.
## HOW TO USE IT
Users can explore how the time extension represents time by:
* Setting the dates and times at which the simulation starts and ends by editing the `sim-start-time` and `sim-end-time` inputs on the Interface. These are text strings that must be in the format: "yyyy/M/d HH:mm:ss" (year, month, day, hour, minute, seconds).
Note that changes in the time step units and length only take effect in the `setup` procedure. Changing them during a simulation has no effect--you must set up again for changes in start time, end time, or the time step to take effect.
Setting the Interface to view updates on ticks (instead of "Continuous") may make the model run slow enough to observe; if not, turn down the speed slider.
## THINGS TO NOTICE
Non-integer time step lengths are not supported for units of "months" or "years"; for months and years, the time step length will be rounded to the nearest whole number. (Try it!)
## THINGS TO TRY
Change the time step units in the chooser and the time step length in the slider, hit `setup` and `step` to see exactly how the time extension works. For example:
* What happens to the date and day of year when leap day arrives?
If you prefer a different format for date and time input (`sim-start-time` and `sim-end-time`), try changing the two `time:create-with-format` statements in `setup` to use your preferred format.
## RELATED MODELS
The NetLogo models library contains other example uses of the time extension, in its Code Examples > Extension Examples section.
## CREDITS AND REFERENCES
This model was drafted by Steve Railsback
(back to the NetLogo User Community Models)