Nelson banner
Date and Time

The Time Functions module provides tools for working with dates, times, and durations in Nelson.

It supports querying the current time, measuring elapsed time, performing calculations on dates and times, converting between different time representations, and handling calendar-specific operations such as leap years and month-end calculations.

This module enables precise time management, scheduling, and performance measurement in scripts and applications.

Create Date and Time Arrays

Functions for creating date and time values and alternate date representations.

  • NaT
    Create not-a-time datetime values.
  • calendar
    Calendar.
  • clock
    Return the current local date and time as a date vector.
  • date
    Return the Current date as character vector.
  • datenum
    Return the date/time input as a serial day number.
  • datetime
    Create datetime arrays from calendar parts, text, or numeric date representations.
  • datevec
    Convert a serial date number into a date vector.
  • eomdate
    Return the serial date number of the last day in a month.
  • eomday
    Returns last day of month.
  • lweekdate
    Return the last selected weekday in a month.
  • now
    Returns current date under the form of a Unix hour.
  • nweekdate
    Return the nth selected weekday in a month.
  • today
    Return the serial date number for the current day.
Duration and Calendar Duration

Functions for fixed-length and calendar-based durations.

  • caldays
    Create calendar durations containing whole days.
  • calendarDuration
    Create calendar durations with month, day, and time components.
  • calmonths
    Create calendar durations containing calendar months.
  • calquarters
    Create calendar durations containing calendar quarters.
  • calweeks
    Create calendar durations containing whole weeks.
  • calyears
    Create calendar durations containing calendar years.
  • days
    Create durations from days or convert durations to days.
  • duration
    Create elapsed time durations.
  • hours
    Create durations from hours or convert durations to hours.
  • milliseconds
    Create durations from milliseconds or convert durations to milliseconds.
  • minutes
    Create durations from minutes or convert durations to minutes.
  • seconds
    Create durations from seconds or extract seconds from durations.
  • years
    Create durations from years or convert durations to years.
Date and Time Components

Functions for extracting and splitting date and time components.

  • day
    Extract day information from date and time values.
  • hms
    Split datetime or duration values into hour, minute, and second components.
  • hour
    Hours part of the input date and time.
  • minute
    Minutes part of the input date and time.
  • month
    Extract month numbers or names from date and time values.
  • quarter
    Extract quarter numbers from date and time values.
  • second
    Seconds part of the input date and time.
  • timeofday
    Return the elapsed time since midnight for datetime values.
  • week
    Compute week numbers within the calendar year.
  • weekday
    Return the day of week.
  • weeknum
    Return week numbers within the calendar year.
  • year
    Extract year numbers from date and time values.
  • ymd
    Split datetime values into year, month, and day components.
Date Arithmetic and Ranges

Functions for date shifts, differences, ranges, and elapsed time.

  • addtodate
    Modify date number by field.
  • between
    Return calendar durations between two datetime values.
  • caldiff
    Return calendar differences between adjacent datetime values.
  • dateshift
    Shift datetime values to calendar boundaries or selected weekdays.
  • etime
    Time elapsed between date vectors.
  • isbetween
    Test whether datetime values lie inside an interval.
  • months
    Return whole calendar months between two dates.
Query Date and Time Arrays

Predicates and query functions for date, time, duration, and timezone data.

  • iscalendarduration
    Test whether an input is a calendarDuration array.
  • isdatetime
    Test whether an input is a datetime array.
  • isdst
    Test whether timezone-aware datetime values are in daylight saving time.
  • isduration
    Test whether an input is a duration array.
  • isnat
    Test datetime values for not-a-time elements.
  • isregular
    Test whether datetime values are regularly spaced.
  • istimeseries
    Determine whether input is a timeseries object.
  • isweekend
    Test whether date values fall on Saturday or Sunday.
  • leapseconds
    Return leap second data available to the time module.
  • leapyear
    Determine leap year.
  • timezones
    List timezone names available in the embedded timezone data.
  • tzoffset
    Return UTC offsets for timezone-aware datetime values.
Text and External Time Systems

Conversions between date and time values, text, and external numeric time systems.

  • convertTo
    Convert datetime values to selected numeric representations.
  • datestr
    Convert date and time to string format.
  • exceltime
    Convert datetime values to spreadsheet serial date numbers.
  • juliandate
    Convert datetime values to Julian date numbers.
  • m2xdate
    Convert Nelson serial dates to spreadsheet serial date numbers.
  • posixtime
    Convert datetime values to seconds elapsed since the POSIX epoch.
  • x2mdate
    Convert spreadsheet serial date numbers to Nelson serial dates or datetime values.
  • yyyymmdd
    Convert date values to numeric yyyymmdd calendar dates.
Timers and Timing

Timer objects, scheduling, waits, and timing utilities.

  • cputime
    Return the CPU time used by your Nelon session.
  • sleep
    Suspend code execution.
  • start
    Start a timer object.
  • timer.start
    Start a timer object.
  • startat
    Start a timer at a specified date and time.
  • timer.startat
    Start a timer at a specified date and time.
  • stop
    Stop a running timer object.
  • timer.stop
    Stop a running timer object.
  • tic
    Starts a stopwatch timer.
  • time
    Return the current time as the number of seconds or nanoseconds since the epoch.
  • timeit
    Measure time required to run function.
  • timer.delete
    Stop and invalidate timer objects.
  • delete timer
    Stop and invalidate timer objects.
  • timer.get
    Get timer property values.
  • get timer
    Get timer property values.
  • timer.isvalid
    Determine which timer handles are valid.
  • isvalid timer
    Determine which timer handles are valid.
  • timer.set
    Set timer property values.
  • set timer
    Set timer property values.
  • timer
    Create a timer object that runs commands after a delay or at repeated intervals.
  • timer object
    Create a timer object that runs commands after a delay or at repeated intervals.
  • Timer Callback Functions
    Define commands that execute when timer events occur.
  • timer callback functions
    Define commands that execute when timer events occur.
  • timer callbacks
    Define commands that execute when timer events occur.
  • Timer Queuing Conflicts
    Control what happens when timer callbacks are still queued when a fixed-rate timer fires again.
  • handling timer queuing conflicts
    Control what happens when timer callbacks are still queued when a fixed-rate timer fires again.
  • timer busy mode
    Control what happens when timer callbacks are still queued when a fixed-rate timer fires again.
  • timerfind
    Find visible timer objects that match property criteria.
  • timerfindall
    Find all timer objects that match property criteria, including hidden timers.
  • toc
    Read the stopwatch timer.
  • wait
    Wait for timer objects to stop.
  • timer.wait
    Wait for timer objects to stop.
Time Series

Time series, time series collections, events, metadata, and related operations.