<spanid="evennia-utils-gametime"></span><h1>evennia.utils.gametime<aclass="headerlink"href="#module-evennia.utils.gametime"title="Permalink to this headline">¶</a></h1>
<p>The gametime module handles the global passage of time in the mud.</p>
<p>It also supplies some useful methods to convert between
in-mud time and real-world time as well allows to get the
total runtime of the server and the current uptime.</p>
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.utils.gametime.</code><codeclass="sig-name descname">TimeScript</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="o">*</span><spanclass="n">args</span></em>, <emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/gametime.html#TimeScript"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.gametime.TimeScript"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">at_script_creation</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/gametime.html#TimeScript.at_script_creation"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.gametime.TimeScript.at_script_creation"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">at_repeat</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/gametime.html#TimeScript.at_repeat"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.gametime.TimeScript.at_repeat"title="Permalink to this definition">¶</a></dt>
<emclass="property">exception </em><codeclass="sig-name descname">DoesNotExist</code><aclass="headerlink"href="#evennia.utils.gametime.TimeScript.DoesNotExist"title="Permalink to this definition">¶</a></dt>
<emclass="property">exception </em><codeclass="sig-name descname">MultipleObjectsReturned</code><aclass="headerlink"href="#evennia.utils.gametime.TimeScript.MultipleObjectsReturned"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">path</code><emclass="property"> = 'evennia.utils.gametime.TimeScript'</em><aclass="headerlink"href="#evennia.utils.gametime.TimeScript.path"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">typename</code><emclass="property"> = 'TimeScript'</em><aclass="headerlink"href="#evennia.utils.gametime.TimeScript.typename"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-prename descclassname">evennia.utils.gametime.</code><codeclass="sig-name descname">runtime</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/gametime.html#runtime"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.gametime.runtime"title="Permalink to this definition">¶</a></dt>
<dd><p>Get the total runtime of the server since first start (minus
downtimes)</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>format</strong> (<em>bool</em><em>, </em><em>optional</em>) – Format into a time representation.</p>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><p><em>time (float or tuple)</em>–</p>
<dlclass="simple">
<dt>The runtime or the same time split up</dt><dd><p>into time units.</p>
<codeclass="sig-prename descclassname">evennia.utils.gametime.</code><codeclass="sig-name descname">server_epoch</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/gametime.html#server_epoch"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.gametime.server_epoch"title="Permalink to this definition">¶</a></dt>
<dd><p>Get the server epoch. We may need to calculate this on the fly.</p>
<codeclass="sig-prename descclassname">evennia.utils.gametime.</code><codeclass="sig-name descname">uptime</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/gametime.html#uptime"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.gametime.uptime"title="Permalink to this definition">¶</a></dt>
<dd><p>Get the current uptime of the server since last reload</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>format</strong> (<em>bool</em><em>, </em><em>optional</em>) – Format into time representation.</p>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><p><em>time (float or tuple)</em>–</p>
<dlclass="simple">
<dt>The uptime or the same time split up</dt><dd><p>into time units.</p>
<codeclass="sig-prename descclassname">evennia.utils.gametime.</code><codeclass="sig-name descname">portal_uptime</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/gametime.html#portal_uptime"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.gametime.portal_uptime"title="Permalink to this definition">¶</a></dt>
<dd><p>Get the current uptime of the portal.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Returns</dt>
<ddclass="field-odd"><p><em>time (float)</em>– The uptime of the portal.</p>
<codeclass="sig-prename descclassname">evennia.utils.gametime.</code><codeclass="sig-name descname">game_epoch</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/gametime.html#game_epoch"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.gametime.game_epoch"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-prename descclassname">evennia.utils.gametime.</code><codeclass="sig-name descname">gametime</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">absolute</span><spanclass="o">=</span><spanclass="default_value">False</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/gametime.html#gametime"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.gametime.gametime"title="Permalink to this definition">¶</a></dt>
<divclass="highlight-default notranslate"><divclass="highlight"><pre><span></span><spanclass="n">schedule</span><spanclass="p">(</span><spanclass="n">func</span><spanclass="p">,</span><spanclass="nb">min</span><spanclass="o">=</span><spanclass="mi">5</span><spanclass="p">,</span><spanclass="n">sec</span><spanclass="o">=</span><spanclass="mi">0</span><spanclass="p">)</span><spanclass="c1"># Will call 5 minutes past the next (in-game) hour.</span>
<spanclass="n">schedule</span><spanclass="p">(</span><spanclass="n">func</span><spanclass="p">,</span><spanclass="n">hour</span><spanclass="o">=</span><spanclass="mi">2</span><spanclass="p">,</span><spanclass="nb">min</span><spanclass="o">=</span><spanclass="mi">30</span><spanclass="p">,</span><spanclass="n">sec</span><spanclass="o">=</span><spanclass="mi">0</span><spanclass="p">)</span><spanclass="c1"># Will call the next (in-game) day at 02:30.</span>
<codeclass="sig-prename descclassname">evennia.utils.gametime.</code><codeclass="sig-name descname">reset_gametime</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/gametime.html#reset_gametime"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.gametime.reset_gametime"title="Permalink to this definition">¶</a></dt>
<dd><p>Resets the game time to make it start from the current time. Note that
the epoch set by <strong>settings.TIME_GAME_EPOCH</strong> will still apply.</p>