nk 1.0.0
C++ Numerical Computing Runtime
Loading...
Searching...
No Matches
timefun.hpp
Go to the documentation of this file.
1// src/builtin/include/nk/builtin/timefun.hpp
2//
3// Pure C++ Date and time functions, execution timing, calendar, and conversions.
4#pragma once
5
6#include <memory_resource>
7#include <string>
8#include <nk/value/value.hpp>
9#include <nk/value/span.hpp>
10
11namespace nk::builtin {
12
15
16
23
24// ── Timing & Benchmarking ───────────────────────────────────────────────────
25
32double cputime();
33
40void pause(double seconds);
41
42// ── Date and Clock ──────────────────────────────────────────────────────────
43
47double now();
48
52std::string date();
53
58Value clock(std::pmr::memory_resource *mr = nullptr);
59
66Value etime(const Value &t2, const Value &t1, std::pmr::memory_resource *mr = nullptr);
67
73Value datenum(Span<const Value> args, std::pmr::memory_resource *mr = nullptr);
74
80Value datestr(Span<const Value> args, std::pmr::memory_resource *mr = nullptr);
81
87Value datevec(Span<const Value> args, std::pmr::memory_resource *mr = nullptr);
88
94Value weekday(const Value &d, std::pmr::memory_resource *mr = nullptr);
95
102Value eomday(const Value &y, const Value &m, std::pmr::memory_resource *mr = nullptr);
103
109Value calendar(Span<const Value> args, std::pmr::memory_resource *mr = nullptr);
110
116Value juliandate(Span<const Value> args, std::pmr::memory_resource *mr = nullptr);
117
123Value mjuliandate(Span<const Value> args, std::pmr::memory_resource *mr = nullptr);
124
129Value weeknum(Span<const Value> args, std::pmr::memory_resource *mr = nullptr);
130
137Value addtodate(const Value &d, double quantity, const std::string &unit, std::pmr::memory_resource *mr = nullptr);
138
143Value yyyymmdd(Span<const Value> args, std::pmr::memory_resource *mr = nullptr);
144
145
147} // namespace nk::builtin
Core MATLAB-compatible multidimensional array and scalar value type.
Definition value.hpp:61
Value weekday(const Value &d, std::pmr::memory_resource *mr=nullptr)
Day of week for date number or text (weekday(d)).
Value calendar(Span< const Value > args, std::pmr::memory_resource *mr=nullptr)
Generates 6x7 calendar matrix for year and month (calendar(...)).
Value datestr(Span< const Value > args, std::pmr::memory_resource *mr=nullptr)
Formats serial date number or date vector into text string (datestr(...)).
Value datevec(Span< const Value > args, std::pmr::memory_resource *mr=nullptr)
Converts serial date number or text into date vector matrix [Y, M, D, H, MI, S] (datevec(....
double cputime()
Total CPU time consumed by the current process in seconds (cputime).
Value clock(std::pmr::memory_resource *mr=nullptr)
Current date and time as a 6-element vector [Y, M, D, H, MI, S] (clock).
void pause(double seconds)
Halts execution for specified number of seconds (pause(n)).
double now()
Current date and time as a serial date number (now).
Value datenum(Span< const Value > args, std::pmr::memory_resource *mr=nullptr)
Converts date components or string to serial date number (datenum(...)).
Value juliandate(Span< const Value > args, std::pmr::memory_resource *mr=nullptr)
Julian date number from serial date or date components (juliandate(...)).
Value mjuliandate(Span< const Value > args, std::pmr::memory_resource *mr=nullptr)
Modified Julian date number (mjuliandate(...)).
Value etime(const Value &t2, const Value &t1, std::pmr::memory_resource *mr=nullptr)
Elapsed time in seconds between two date vectors (etime(t2, t1)).
Value weeknum(Span< const Value > args, std::pmr::memory_resource *mr=nullptr)
Week number of the year for a given date (weeknum(...)).
Value yyyymmdd(Span< const Value > args, std::pmr::memory_resource *mr=nullptr)
Formats date number as ISO integer YYYYMMDD (yyyymmdd(...)).
std::string date()
Current date as formatted text 'dd-mmm-yyyy' (date).
Value addtodate(const Value &d, double quantity, const std::string &unit, std::pmr::memory_resource *mr=nullptr)
Shifts date by quantity in specified time units (addtodate(d, q, unit)).
Value eomday(const Value &y, const Value &m, std::pmr::memory_resource *mr=nullptr)
End of month day for year and month (eomday(y, m)).