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

time

time

time -- unit feature to group time related features

Constructors

:
orderable
 is
[Private constructor]
time.calendar_duration -- value representing a duration in the ISO 8601
calendar
 ref
:
effect
 is
[Contains abstract features]
time.Clock -- class of effects that implement a clock

This is a `ref` feature such that code that requires an arbitrary `Clock`
effect could be written in a way that permits its execution using different
actual `Clock` implementations like `time.nano` that provides high
precision with low accuray or a different clock that provides higher accuracy.
(year i32, month i32, day i32, hour i32, minute i32, second i32, nano_second i32)
:
orderable
 is
Represents a date and a time in the Gregorian calendar, without any specification of
a time zone or reference point.
:
orderable
 is
[Private constructor]
time.duration -- value representing a duration, i.e., a time span

This is intended for high precision time specification and measurement, it
uses a time resolution of 1ns.

The maximum value is about 580 years, so this is not intended for use in
calendars that may require time spans exceeding several centuries or millennia,
nor astrological time spans.
(title String, period option time.duration, max_recorded option time.duration, ignore_first u64, ignore_last u64)
:
Any
 is
time.histogram -- feature to collect and output timing data

This is particularly useful to analyse variations in release or
execution times of repeatedly executed tasks or events.

For this, it distributes time.duration values into a list of
buckets that correspond to different ranges of durations. These
buckets may be equally spaced (linear) or growing by an equal
factor (logarithmic).

The use of buckets permits the collection of large numbers of
sampe durations since only the counts per bucket are recorded
:
orderable
 is
[Private constructor]
time.instant -- abstract moment in time used for measuring durations

An instant is an absolute time relative to some fixed start of an epoch
that depends on the clock that created this instant.

NYI: UNDER DEVELOPMENT: we might want to add a reference to the clock that
created this instant and verify that `infix -` is called only on `instant`s
created by the same clock.
(p time.this.Nano_Time_Handler)
:
Clock
 is
[Contains abstract features]
time.nano -- effect providing nano time

time.nano is a timer that provides high precision but possibly low
accuracy. Such a timer is typically useful for timing the duration
of events, such as measuring the time it takes to perform some
calculation.

time.nano may have a significant drift compared to actual time, it might
not be the right source of time to, e.g., feed an alarm clock that should
wake you up at 6h30 every morning.
 ref
:
Any
 is
[Private constructor]
abstract handler that can deliver a nano time
effect for getting the current date_time
time.duration.unit -- unit type defining units used in duration

time units used to present durations as Strings to humans to read

Functions

 => 
String
[Inherited from  Any]
create a String from this instance. Unless redefined, `a.as_string` will
create `"instance[T]"` where `T` is the dynamic type of `a`
 => 
Type
[Inherited from  Any]
Get the dynamic type of this instance. For value instances `x`, this is
equal to `type_of x`, but for `x` with a `ref` type `x.dynamic_type` gives
the actual runtime type, while `type_of x` results in the static
compile-time type.

There is no dynamic type of a type instance since this would result in an
endless hierarchy of types. So for Type values, dynamic_type is redefined
to just return Type.type.
(year i32, month i32, day i32)
 => 
bool
is the given date valid?
short-hand for accessing time.nano effect in current environment
get the current date_time.
Uses currently installed time.now effect
or installs the default_now handler
 => 
String
[Inherited from  Any]
convenience prefix operator to create a string from a value.

This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
stopwatch measures the execution duration of f

Type Functions

 => 
String
[Inherited from  Type]
string representation of this type to be used for debugging.

result has the form "Type of '<name>'", but this might change in the future

redefines:

 => 
Type
[Inherited from  Type]
There is no dynamic type of a type instance since this would result in an
endless hierarchy of types, so dynamic_type is redefined to just return
Type.type here.

redefines:

(T 
type
:
Type)
 => 
bool
[Inherited from  Type]
Is this type assignable to a type parameter with constraint `T`?

The result of this is a compile-time constant that can be used to specialize
code for a particular type.


it is most useful in conjunction with preconditions or `if` statements as in


or

 => 
String
[Inherited from  Type]
name of this type, including type parameters, e.g. 'option (list i32)'.
 => 
String
[Inherited from  Type]
convenience prefix operator to create a string from a value.

This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.

NYI: Redefinition allows the type feature to be distinguished from its normal counterpart, see #3913

redefines:

 => 
Type
[Inherited from  Any]
Get a type as a value.

This is a feature with the effect equivalent to Fuzion's `expr.type` call tail.
It is recommended to use `expr.type` and not `expr.type_value`.

`type_value` is here to show how this can be implemented and to illustrate the
difference to `dynamic_type`.
0.095dev (2025-08-15 12:02:22 GIT hash 301b5b75e77076d091b38f555473f9f0e31e5b5c built by fridi@fzen)