Fuzion Logo
fuzion-lang.dev — The Fuzion Language Portal
JavaScript seems to be disabled. Functionality is limited.

time/now.fz


# This file is part of the Fuzion language implementation.
#
# The Fuzion language implementation is free software: you can redistribute it
# and/or modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, version 3 of the License.
#
# The Fuzion language implementation is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
# License for more details.
#
# You should have received a copy of the GNU General Public License along with The
# Fuzion language implementation.  If not, see <https://www.gnu.org/licenses/>.


# -----------------------------------------------------------------------
#
#  Tokiwa Software GmbH, Germany
#
#  Source code of Fuzion standard library feature time.now
#
#  Author: Michael Lill (michael.lill@tokiwa.software)
#
# -----------------------------------------------------------------------

# effect for getting the current date_time
public now (p () -> time.date_time) : effect is

  # get current date_time
  #
  public get time.date_time =>
    res := p()
    replace
    res


  # default handler for now effect.
  # returns the current date_time
  # the system is giving us.
  #
  # this default handler fills the result with the UTC time of
  # the current system.
  #
  # NYI: UNDER DEVELOPMENT: since Fuzion does not properly support datetimes with
  # timezones, these results need to be handled with care.
  #
  type.default_now ()->time.date_time => () ->

    a := fuzion.sys.internal_array_init i32 7
    fzE_date_time a.data
    time.date_time a[0] a[1] a[2] a[3] a[4] a[5] a[6]


  type.install_default =>
    (time.now default_now).default


# get the current date_time.
# Uses currently installed time.now effect
# or installs the default_now handler
#
public now now =>
  now.install_default
  now.env

last changed: 2025-07-10