Next: Introduction [Contents]
This manual is for Chrono, version 0.3.1.
| • Introduction | ||
| • Getting Started | ||
| • Date Representation | ||
| • Time Zones | ||
| • Durations | ||
| • Missing Functionality | ||
| • Function Reference | ||
| • Copying |
Next: Getting Started, Up: Top [Contents]
Time is an illusion. Lunchtime doubly so.
This is the manual for the Chrono package version 0.3.1 for GNU Octave.
This document is a work in progress. You are invited to help improve it and submit patches.
Chrono provides date/time functionality for Octave by supplying Matlab-compatible
implementations for the datetime, duration, and calendarDuration
classes, along with related functions.
Chrono’s classes are designed to be convenient to use while still being efficient. The data representations used by Chrono are designed to be efficient and suitable for working with large-ish data sets. A “large-ish” data set is one that can have millions of elements or rows, but still fits in main computer memory. Chrono’s main relational and arithmetic operations are all implemented using vectorized operations on primitive Octave data types.
Chrono was written by Andrew Janke <floss@apjanke.net>. Support can be found on the Chrono project GitHub page.
Next: Date Representation, Previous: Introduction, Up: Top [Contents]
The easiest way to obtain Chrono is by using Octave’s pkg package manager.
To install the a development prerelease of Chrono, run this in Octave:
pkg install https://github.com/apjanke/octave-chrono/releases/download/v0.3.1/chrono-0.3.1.tar.gz
(Check the releases page at https://github.com/apjanke/octave-chrono/releases to find out what the actual latest release number is.)
For development, you can obtain the source code for Chrono from the project repo on GitHub at https://github.com/apjanke/octave-chrono. Upon first installation, run the octave_chrono_make_local script to build the octfiles so Chrono will work. Then add the inst directory in the repo to your Octave path.
Next: Time Zones, Previous: Getting Started, Up: Top [Contents]
Chrono provides the datetime class for representing points in time.
| • datetime Class |
Up: Date Representation [Contents]
datetime ClassA datetime is an array object that represents points in time in the familiar
Gregorian calendar.
This is an attempt to reproduce the functionality of Matlab’s datetime. It
also contains some Octave-specific extensions.
The underlying representation is that of a datenum (a double
containing the number of days since the Matlab epoch), but encapsulating it in an
object provides several benefits: friendly human-readable display, type safety,
automatic type conversion, and time zone support. In addition to the underlying
datenum array, a datetime inclues an optional TimeZone property
indicating what time zone the datetimes are in.
• datenum Compatibility |
Up: datetime Class [Contents]
datenum CompatibilityWhile the underlying data representation of datetime is compatible with
(in fact, identical to) that of datenums, you cannot directly combine them
via assignment, concatenation, or most arithmetic operations.
This is because of the signature of the datetime constructor. When combining
objects and primitive types like double, the primitive type is promoted to an
object by calling the other object’s one-argument constructor on it. However, the
one-argument numeric-input consstructor for datetime does not accept datenums:
it interprets its input as datevecs instead. This is due to a design decision on
Matlab’s part; for compatibility, Octave does not alter that interface.
To combine datetimes with datenums, you can convert the datenums to datetimes
by calling datetime.ofDatenum or datetime(x, 'ConvertFrom', 'datenum'), or you
can convert the datetimes to datenums by accessing its dnums field with
x.dnums.
Examples:
dt = datetime('2011-03-04')
dn = datenum('2017-01-01')
[dt dn]
⇒ error: datenum: expected date vector containing [YEAR, MONTH, DAY, HOUR, MINUTE, SECOND]
[dt datetime.ofDatenum(dn)]
⇒ 04-Mar-2011 01-Jan-2017
Also, if you have a zoned datetime, you can’t combine it with a datenum, because datenums
do not carry time zone information.
Next: Durations, Previous: Date Representation, Up: Top [Contents]
Chrono has support for representing dates in time zones and for converting between time zones.
A datetime may be "zoned" or "zoneless". A zoneless datetime does not have a time zone
associated with it. This is represented by an empty TimeZone property on the datetime
object. A zoneless datetime represents the local time in some unknown time zone, and assumes a
continuous time scale (no DST shifts).
A zoned datetime is associated with a time zone. It is represented by having the time zone’s
IANA zone identifier (e.g. 'UTC' or 'America/New_York') in its TimeZone
property. A zoned datetime represents the local time in that time zone.
By default, the datetime constructor creates unzoned datetimes. To
make a zoned datetime, either pass the 'TimeZone' option to the constructor,
or set the TimeZone property after object creation. Setting the TimeZone
property on a zoneless datetime declares that it’s a local time in that time zone.
Setting the TimeZone property on a zoned datetime turns it back into a
zoneless datetime without changing the local time it represents.
You can tell a zoned from a zoneless time zone in the object display because the time zone
is included for zoned datetimes.
% Create an unzoned datetime
d = datetime('2011-03-04 06:00:00')
⇒ 04-Mar-2011 06:00:00
% Create a zoned datetime
d_ny = datetime('2011-03-04 06:00:00', 'TimeZone', 'America/New_York')
⇒ 04-Mar-2011 06:00:00 America/New_York
% This is equivalent
d_ny = datetime('2011-03-04 06:00:00');
d_ny.TimeZone = 'America/New_York'
⇒ 04-Mar-2011 06:00:00 America/New_York
% Convert it to Chicago time
d_chi.TimeZone = 'America/Chicago'
⇒ 04-Mar-2011 05:00:00 America/Chicago
When you combine two zoned datetimes via concatenation, assignment, or
arithmetic, if their time zones differ, they are converted to the time zone of
the left-hand input.
d_ny = datetime('2011-03-04 06:00:00', 'TimeZone', 'America/New_York')
d_la = datetime('2011-03-04 06:00:00', 'TimeZone', 'America/Los_Angeles')
d_la - d_ny
⇒ 03:00:00
You cannot combine a zoned and an unzoned datetime. This results in an error
being raised.
Warning: Normalization of "nonexistent" times (like between 02:00 and 03:00 on a "spring forward" DST change day) is not implemented yet. The results of converting a zoneless local time into a time zone where that local time did not exist are currently undefined.
| • Defined Time Zones |
Up: Time Zones [Contents]
Chrono’s time zone data is drawn from the IANA Time Zone Database, also known as the “Olson Database”. Chrono includes a copy of this database in its distribution so it can work on Windows, which does not supply it like Unix systems do.
You can use the timezones function to list the time zones known to Chrono. These will be
all the time zones in the IANA database on your system (for Linux and macOS) or in the IANA
time zone database redistributed with Chrono (for Windows).
Note: The IANA Time Zone Database only covers dates from about the year 1880 to 2038. Converting time zones for
datetimes outside that range is currently unimplemented. (Chrono needs to add support for proleptic POSIX time zone rules, which are used to govern behavior outside that date range.)
Next: Missing Functionality, Previous: Time Zones, Up: Top [Contents]
| • duration Class | ||
| • calendarDuration Class |
Next: calendarDuration Class, Up: Durations [Contents]
duration ClassA duration represents a period of time in fixed-length seconds (or minutes, hours,
or whatever you want to measure it in.)
A duration has a resolution of about a nanosecond for typical dates. The underlying
representation is a double representing the number of days elapsed, similar to a
datenum, except it’s interpreted as relative to some other reference point you provide,
instead of being relative to the Matlab/Octave epoch.
You can add or subtract a duration to a datetime to get another datetime.
You can also add or subtract durations to each other.
Previous: duration Class, Up: Durations [Contents]
calendarDuration ClassA calendarDuration represents a period of time in variable-length calendar
components. For example, years and months can have varying numbers of days, and days
in time zones with Daylight Saving Time have varying numbers of hours. A
calendarDuration does arithmetic with "whole" calendar periods.
calendarDurations and durations cannot be directly combined, because
they are not semantically equivalent. (This may be relaxed in the future to allow
durations to be interpreted as numbers of days when combined with
calendarDurations.)
d = datetime('2011-03-04 00:00:00')
⇒ 04-Mar-2011
cdur = calendarDuration(1, 3, 0)
⇒ 1y 3mo
d2 = d + cdur
⇒ 04-Jun-2012
Next: Function Reference, Previous: Durations, Up: Top [Contents]
Chrono is based on Matlab’s date/time API and supports most of its major functionality. But not all of it is implemented yet. The missing parts are currently:
'ConvertFrom' forms for datetime and duration
datetime
between, caldiff, dateshift, week
isdst, isweekend
calendarDuration.split
duration.Format support
UTCOffset and DSTOffset fields in the output of timezones()
It is the author’s hope that all these will be implemented some day.
Next: Copying, Previous: Missing Functionality, Up: Top [Contents]
| • Functions by Category | ||
| • Functions Alphabetically |
Next: Functions Alphabetically, Up: Function Reference [Contents]
’datetime’ represents points in time using the Gregorian calendar.
True if input is a ’datetime’ array, false otherwise.
“Not-a-Time”.
Durations of time using variable-length calendar periods, such as days, months, and years, which may vary in length over time.
Create a ’calendarDuration’ that is a given number of calendar months long.
Construct a ’calendarDuration’ a given number of years long.
Duration in days.
Represents durations or periods of time as an amount of fixed-length time (i.e.
Create a ’duration’ X hours long, or get the hours in a ’duration’ X.
True if input is a ’duration’ array, false otherwise.
Create a ’duration’ X milliseconds long, or get the milliseconds in a ’duration’ X.
Create a ’duration’ X hours long, or get the hours in a ’duration’ X.
Create a ’duration’ X seconds long, or get the seconds in a ’duration’ X.
List all the time zones defined on this system.
Create a ’duration’ X years long, or get the years in a ’duration’ X.
Previous: Functions by Category, Up: Function Reference [Contents]
| • calendarDuration | Durations of time using variable-length calendar periods, such as days, months, and years, which may vary in length over time. | |
| • calmonths | Create a ’calendarDuration’ that is a given number of calendar months long. | |
| • calyears | Construct a ’calendarDuration’ a given number of years long. | |
| • datetime | ’datetime’ represents points in time using the Gregorian calendar. | |
| • days | Duration in days. | |
| • duration | Represents durations or periods of time as an amount of fixed-length time (i.e. | |
| • hours | Create a ’duration’ X hours long, or get the hours in a ’duration’ X. | |
| • isdatetime | True if input is a ’datetime’ array, false otherwise. | |
| • isduration | True if input is a ’duration’ array, false otherwise. | |
| • milliseconds | Create a ’duration’ X milliseconds long, or get the milliseconds in a ’duration’ X. | |
| • minutes | Create a ’duration’ X hours long, or get the hours in a ’duration’ X. | |
| • NaT | “Not-a-Time”. | |
| • seconds | Create a ’duration’ X seconds long, or get the seconds in a ’duration’ X. | |
| • timezones | List all the time zones defined on this system. | |
| • years | Create a ’duration’ X years long, or get the years in a ’duration’ X. |
Next: calmonths, Up: Functions Alphabetically [Contents]
Durations of time using variable-length calendar periods, such as days, months, and years, which may vary in length over time. (For example, a calendar month may have 28, 30, or 31 days.)
char SignThe sign (1 or -1) of this duration, which indicates whether it is a positive or negative span of time.
char YearsThe number of whole calendar years in this duration. Must be integer-valued.
char MonthsThe number of whole calendar months in this duration. Must be integer-valued.
char DaysThe number of whole calendar days in this duration. Must be integer-valued.
char HoursThe number of whole hours in this duration. Must be integer-valued.
char MinutesThe number of whole minutes in this duration. Must be integer-valued.
char SecondsThe number of seconds in this duration. May contain fractional values.
char FormatThe format to display this calendarDuration in. Currently unsupported.
This is a single value that applies to the whole array.
Next: calendarDuration.isnat, Up: calendarDuration [Contents]
Constructs a new scalar calendarDuration of zero elapsed time.
Constructs new calendarDuration arrays based on input values.
Next: calendarDuration.uminus, Previous: calendarDuration.calendarDuration, Up: calendarDuration [Contents]
True if input elements are NaT.
Returns logical array the same size as obj.
Next: calendarDuration.plus, Previous: calendarDuration.isnat, Up: calendarDuration [Contents]
Unary minus. Negates the sign of obj.
Next: calendarDuration.times, Previous: calendarDuration.uminus, Up: calendarDuration [Contents]
Addition: add two calendarDurations.
All the calendar elements (properties) of the two inputs are added together. No normalization is done across the elements, aside from the normalization of NaNs.
If B is numeric, it is converted to a calendarDuration
using calendarDuration.ofDays.
Returns a calendarDuration.
Next: calendarDuration.minus, Previous: calendarDuration.plus, Up: calendarDuration [Contents]
Multiplication: Multiplies a calendarDuration by a numeric factor.
Returns a calendarDuration.
Next: calendarDuration.dispstrs, Previous: calendarDuration.times, Up: calendarDuration [Contents]
Subtraction: Subtracts one calendarDuration from another.
Returns a calendarDuration.
Next: calendarDuration.isnan, Previous: calendarDuration.minus, Up: calendarDuration [Contents]
Get display strings for each element of obj.
Returns a cellstr the same size as obj.
Previous: calendarDuration.dispstrs, Up: calendarDuration [Contents]
True if input elements are NaT. This is just an alias for isnat,
provided for compatibility and polymorphic programming purposes.
Returns logical array the same size as obj.
Next: calyears, Previous: calendarDuration, Up: Functions Alphabetically [Contents]
Create a calendarDuration that is a given number of calendar months
long.
Input x is a numeric array specifying the number of calendar months.
This is a shorthand alternative to calling the calendarDuration
constructor with calendarDuration(0, x, 0).
Returns a new calendarDuration object of the same size as x.
See calendarDuration.
Next: datetime, Previous: calmonths, Up: Functions Alphabetically [Contents]
Construct a calendarDuration a given number of years long.
This is a shorthand for calling calendarDuration(x, 0, 0).
See calendarDuration.
Next: days, Previous: calyears, Up: Functions Alphabetically [Contents]
datetime represents points in time using the Gregorian calendar.
The underlying values are doubles representing the number of days since the Matlab epoch of "January 0, year 0". This has a precision of around nanoseconds for typical times.
A datetime array is an array of date/time values, with each element
holding a complete date/time. The overall array may also have a TimeZone and a
Format associated with it, which apply to all elements in the array.
This is an attempt to reproduce the functionality of Matlab’s datetime. It
also contains some Octave-specific extensions.
double dnumsThe underlying datenums that represent the points in time. These are always in UTC.
This is a planar property: the size of dnums is the same size as the
containing datetime array object.
char TimeZoneThe time zone this datetime array is in. Empty if this does not have a
time zone associated with it (“unzoned”). The name of an IANA time zone if
this does.
Setting the TimeZone of a datetime array changes the time zone it
is presented in for strings and broken-down times, but does not change the
underlying UTC times that its elements represent.
char FormatThe format to display this datetime in. Currently unsupported.
Next: datetime.ofDatenum, Up: datetime [Contents]
Constructs a new scalar datetime containing the current local time, with
no time zone attached.
'ConvertFrom', inType)'Format', Format, 'InputFormat', InputFormat, 'Locale', InputLocale, 'PivotYear', PivotYear, 'TimeZone', TimeZone)Constructs a new datetime array based on input values.
Next: datetime.ofDatestruct, Previous: datetime.datetime, Up: datetime [Contents]
Converts a datenum array to a datetime array.
Returns an unzoned datetime array of the same size as the input.
Next: datetime.posix2datenum, Previous: datetime.ofDatenum, Up: datetime [Contents]
Converts a datestruct to a datetime array.
A datestruct is a special struct format used by Chrono that has fields Year, Month, Day, Hour, Minute, and Second. It is not a standard Octave datatype.
Returns an unzoned datetime array.
Next: datetime.datenum2posix, Previous: datetime.ofDatestruct, Up: datetime [Contents]
Converts POSIX (Unix) times to datenums
Pdates (numeric) is an array of POSIX dates. A POSIX date is the number of seconds since January 1, 1970 UTC, excluding leap seconds. The output is implicitly in UTC.
Next: datetime.proxyKeys, Previous: datetime.posix2datenum, Up: datetime [Contents]
Converts Octave datenums to Unix dates.
The input datenums are assumed to be in UTC.
Returns a double, which may have fractional seconds.
Next: datetime.ymd, Previous: datetime.datenum2posix, Up: datetime [Contents]
Computes proxy key values for two datetime arrays. Proxy keys are numeric values whose rows have the same equivalence relationships as the elements of the inputs.
This is primarily for Chrono’s internal use; users will typically not need to call it or know how it works.
Returns two 2-D numeric matrices of size n-by-k, where n is the number of elements in the corresponding input.
Next: datetime.hms, Previous: datetime.proxyKeys, Up: datetime [Contents]
Get the Year, Month, and Day components of a obj.
For zoned datetimes, these will be local times in the associated time zone.
Returns double arrays the same size as obj.
Next: datetime.ymdhms, Previous: datetime.ymd, Up: datetime [Contents]
Get the Hour, Minute, and Second components of a obj.
For zoned datetimes, these will be local times in the associated time zone.
Returns double arrays the same size as obj.
Next: datetime.timeofday, Previous: datetime.hms, Up: datetime [Contents]
Get the Year, Month, Day, Hour, Minute, and Second components of a obj.
For zoned datetimes, these will be local times in the associated time zone.
Returns double arrays the same size as obj.
Next: datetime.week, Previous: datetime.ymdhms, Up: datetime [Contents]
Get the time of day (elapsed time since midnight).
For zoned datetimes, these will be local times in the associated time zone.
Returns a duration array the same size as obj.
Next: datetime.dispstrs, Previous: datetime.timeofday, Up: datetime [Contents]
Get the week of the year.
This method is unimplemented.
Next: datetime.datestr, Previous: datetime.week, Up: datetime [Contents]
Get display strings for each element of obj.
Returns a cellstr the same size as obj.
Next: datetime.datestrs, Previous: datetime.dispstrs, Up: datetime [Contents]
Format obj as date strings. Supports all arguments that core Octave’s
datestr does.
Returns date strings as a 2-D char array.
Next: datetime.datestruct, Previous: datetime.datestr, Up: datetime [Contents]
Format obj as date strings, returning cellstr.
Supports all arguments that core Octave’s datestr does.
Returns a cellstr array the same size as obj.
Next: datetime.posixtime, Previous: datetime.datestrs, Up: datetime [Contents]
Converts this to a "datestruct" broken-down time structure.
A "datestruct" is a format of struct that Chrono came up with. It is a scalar struct with fields Year, Month, Day, Hour, Minute, and Second, each containing a double array the same size as the date array it represents.
The values in the returned broken-down time are those of the local time in this’ defined time zone, if it has one.
Returns a struct with fields Year, Month, Day, Hour, Minute, and Second. Each field contains a double array of the same size as this.
This is an Octave extension.
Next: datetime.datenum, Previous: datetime.datestruct, Up: datetime [Contents]
Converts this to POSIX time values (seconds since the Unix epoch)
Converts this to POSIX time values that represent the same time. The returned values will be doubles that may include fractional second values. POSIX times are, by definition, in UTC.
Returns double array of same size as this.
Next: datetime.isnat, Previous: datetime.posixtime, Up: datetime [Contents]
DATENUM Convert this to datenums that represent the same local time
Returns double array of same size as this.
Next: datetime.isnan, Previous: datetime.datenum, Up: datetime [Contents]
True if input elements are NaT.
Returns logical array the same size as obj.
Next: datetime.lt, Previous: datetime.isnat, Up: datetime [Contents]
True if input elements are NaT. This is an alias for isnat
to support type compatibility and polymorphic programming.
Returns logical array the same size as obj.
Next: datetime.le, Previous: datetime.isnan, Up: datetime [Contents]
True if A is less than B. This defines the < operator
for datetimes.
Inputs are implicitly converted to datetime using the one-arg
constructor or conversion method.
Returns logical array the same size as obj.
Next: datetime.ne, Previous: datetime.lt, Up: datetime [Contents]
True if A is less than or equal toB. This defines the <= operator
for datetimes.
Inputs are implicitly converted to datetime using the one-arg
constructor or conversion method.
Returns logical array the same size as obj.
Next: datetime.eq, Previous: datetime.le, Up: datetime [Contents]
True if A is not equal to B. This defines the != operator
for datetimes.
Inputs are implicitly converted to datetime using the one-arg
constructor or conversion method.
Returns logical array the same size as obj.
Next: datetime.ge, Previous: datetime.ne, Up: datetime [Contents]
True if A is equal to B. This defines the == operator
for datetimes.
Inputs are implicitly converted to datetime using the one-arg
constructor or conversion method.
Returns logical array the same size as obj.
Next: datetime.gt, Previous: datetime.eq, Up: datetime [Contents]
True if A is greater than or equal to B. This defines the >= operator
for datetimes.
Inputs are implicitly converted to datetime using the one-arg
constructor or conversion method.
Returns logical array the same size as obj.
Next: datetime.plus, Previous: datetime.ge, Up: datetime [Contents]
True if A is greater than B. This defines the > operator
for datetimes.
Inputs are implicitly converted to datetime using the one-arg
constructor or conversion method.
Returns logical array the same size as obj.
Next: datetime.minus, Previous: datetime.gt, Up: datetime [Contents]
Addition (+ operator). Adds a duration, calendarDuration,
or numeric B to a datetime A.
Numeric B inputs are implicitly converted to duration using
duration.ofDays.
Returns datetime array the same size as A.
Next: datetime.diff, Previous: datetime.plus, Up: datetime [Contents]
Subtraction (- operator). Subtracts a duration,
calendarDuration or numeric B from a datetime A,
or subtracts two datetimes from each other.
If both inputs are datetime, then the output is a duration.
Otherwise, the output is a datetime.
Numeric B inputs are implicitly converted to duration using
duration.ofDays.
Returns an array the same size as A.
Next: datetime.isbetween, Previous: datetime.minus, Up: datetime [Contents]
Differences between elements.
Computes the difference between each successive element in obj, as a
duration.
Returns a duration array the same size as obj.
Next: datetime.linspace, Previous: datetime.diff, Up: datetime [Contents]
Tests whether the elements of obj are between lower and upper.
All inputs are implicitly converted to datetime arrays, and are subject
to scalar expansion.
Returns a logical array the same size as the scalar expansion of the inputs.
Next: datetime.convertDatenumTimeZone, Previous: datetime.isbetween, Up: datetime [Contents]
Linearly-spaced values in date/time space.
Constructs a vector of datetimes that represent linearly spaced points
starting at from and going up to to, with n points in the
vector.
from and to are implicitly converted to datetimes.
n is how many points to use. If omitted, defaults to 100.
Returns an n-long datetime vector.
Previous: datetime.linspace, Up: datetime [Contents]
Convert a datenum from one time zone to another.
dnum is a datenum array to convert.
fromZoneId is a charvec containing the IANA Time Zone identifier for the time zone to convert from.
toZoneId is a charvec containing the IANA Time Zone identifier for the time zone to convert to.
Returns a datenum array the same size as dnum.
Next: duration, Previous: datetime, Up: Functions Alphabetically [Contents]
Duration in days.
If x is numeric, then out is a duration array in units
of fixed-length 24-hour days, with the same size as x.
If x is a duration, then returns a double array the same
size as x indicating the number of fixed-length days that each duration
is.
Next: hours, Previous: days, Up: Functions Alphabetically [Contents]
Represents durations or periods of time as an amount of fixed-length time (i.e. fixed-length seconds). It does not care about calendar things like months and days that vary in length over time.
This is an attempt to reproduce the functionality of Matlab’s duration. It
also contains some Octave-specific extensions.
double daysThe underlying datenums that represent the durations, as number of (whole and fractional) days. These are uniform 24-hour days, not calendar days.
This is a planar property: the size of days is the same size as the
containing duration array object.
char FormatThe format to display this duration in. Currently unsupported.
| • duration.duration | ||
| • duration.ofDays | ||
| • duration.years | ||
| • duration.hours | ||
| • duration.minutes | ||
| • duration.seconds | ||
| • duration.milliseconds | ||
| • duration.dispstrs | ||
| • duration.char | ||
| • duration.linspace |
Next: duration.ofDays, Up: duration [Contents]
Constructs a new scalar duration of zero elapsed time.
'InputFormat', InputFormat)Constructs a new duration array based on input values.
Next: duration.years, Previous: duration.duration, Up: duration [Contents]
Converts a double array representing durations in whole and fractional days
to a duration array. This is the method that is used for implicit conversion
of numerics in many cases.
Returns a duration array of the same size as the input.
Next: duration.hours, Previous: duration.ofDays, Up: duration [Contents]
Equivalent number of years.
Gets the number of fixed-length 365.2425-day years that is equivalent to this duration.
Returns double array the same size as obj.
Next: duration.minutes, Previous: duration.years, Up: duration [Contents]
Equivalent number of hours.
Gets the number of fixed-length 60-minute hours that is equivalent to this duration.
Returns double array the same size as obj.
Next: duration.seconds, Previous: duration.hours, Up: duration [Contents]
Equivalent number of minutes.
Gets the number of fixed-length 60-second minutes that is equivalent to this duration.
Returns double array the same size as obj.
Next: duration.milliseconds, Previous: duration.minutes, Up: duration [Contents]
Equivalent number of seconds.
Gets the number of seconds that is equivalent to this duration.
Returns double array the same size as obj.
Next: duration.dispstrs, Previous: duration.seconds, Up: duration [Contents]
Equivalent number of milliseconds.
Gets the number of milliseconds that is equivalent to this duration.
Returns double array the same size as obj.
Next: duration.char, Previous: duration.milliseconds, Up: duration [Contents]
Get display strings for each element of obj.
Returns a cellstr the same size as obj.
Next: duration.linspace, Previous: duration.dispstrs, Up: duration [Contents]
Convert to char. The contents of the strings will be the same as
returned by dispstrs.
This is primarily a convenience method for use on scalar objs.
Returns a 2-D char array with one row per element in obj.
Previous: duration.char, Up: duration [Contents]
Linearly-spaced values in time duration space.
Constructs a vector of durations that represent linearly spaced points
starting at from and going up to to, with n points in the
vector.
from and to are implicitly converted to durations.
n is how many points to use. If omitted, defaults to 100.
Returns an n-long datetime vector.
Next: isdatetime, Previous: duration, Up: Functions Alphabetically [Contents]
Create a duration x hours long, or get the hours in a duration
x.
If input is numeric, returns a duration array that is that many hours in
time.
If input is a duration, converts the duration to a number of hours.
Returns an array the same size as x.
Next: isduration, Previous: hours, Up: Functions Alphabetically [Contents]
True if input is a datetime array, false otherwise.
Returns a logical array the same size as x.
Next: milliseconds, Previous: isdatetime, Up: Functions Alphabetically [Contents]
True if input is a duration array, false otherwise.
Returns a logical array the same size as x.
Next: minutes, Previous: isduration, Up: Functions Alphabetically [Contents]
Create a duration x milliseconds long, or get the milliseconds in a duration
x.
If input is numeric, returns a duration array that is that many milliseconds in
time.
If input is a duration, converts the duration to a number of milliseconds.
Returns an array the same size as x.
Next: NaT, Previous: milliseconds, Up: Functions Alphabetically [Contents]
Create a duration x hours long, or get the hours in a duration
x.
Next: seconds, Previous: minutes, Up: Functions Alphabetically [Contents]
“Not-a-Time”. Creates NaT-valued arrays.
Constructs a new datetime array of all NaT values of
the given size. If no input sz is given, the result is a scalar NaT.
NaT is the datetime equivalent of NaN. It represents a missing
or invalid value. NaT values never compare equal to, greater than, or less
than any value, including other NaTs. Doing arithmetic with a NaT and
any other value results in a NaT.
Next: timezones, Previous: NaT, Up: Functions Alphabetically [Contents]
Create a duration x seconds long, or get the seconds in a duration
x.
If input is numeric, returns a duration array that is that many seconds in
time.
If input is a duration, converts the duration to a number of seconds.
Returns an array the same size as x.
Next: years, Previous: seconds, Up: Functions Alphabetically [Contents]
List all the time zones defined on this system.
This lists all the time zones that are defined in the IANA time zone database used by this Octave. (On Linux and macOS, that will generally be the system time zone database from /usr/share/zoneinfo. On Windows, it will be the database redistributed with the Chrono package.
If the return is captured, the output is returned as a table if your Octave has table support, or a struct if it does not. It will have fields/variables containing column vectors:
NameThe IANA zone name, as cellstr.
AreaThe geographical area the zone is in, as cellstr.
Compatibility note: Matlab also includes UTCOffset and DSTOffset fields in the output; these are currently unimplemented.
Previous: timezones, Up: Functions Alphabetically [Contents]
Create a duration x years long, or get the years in a duration
x.
If input is numeric, returns a duration array in units of fixed-length
years of 365.2425 days each.
If input is a duration, converts the duration to a number of fixed-length
years as double.
Note: years creates fixed-length years, which may not be what you want.
To create a duration of calendar years (which account for actual leap days),
use calyears.
See calyears.
Previous: Function Reference, Up: Top [Contents]
Chrono for Octave is covered by the GNU GPLv3, the Unicode License, and Public Domain.
All the code in the package is GNU GPLv3.
The IANA Time Zone Database redistributed with the package is Public Domain.
The Windows Zones file redistributed with the package is covered by the Unicode License.
This manual is for Chrono, version 0.3.1.
Copyright © 2019 Andrew Janke
Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies.
Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.
Permission is granted to copy and distribute translations of this manual into another language, under the same conditions as for modified versions.