Vuo  2.0.0
Macros | Typedefs | Functions

Description

A date and time.

Typedefs

typedef double VuoTime
 A date and time. More...
 

Functions

VuoTime VuoTime_makeFromJson (struct json_object *js)
 Decodes the JSON object js to create a new value. More...
 
struct json_objectVuoTime_getJson (const VuoTime value)
 Encodes value as a JSON object. More...
 
char * VuoTime_getSummary (const VuoTime value)
 Returns a compact string representation of value. More...
 
bool VuoTime_areEqual (const VuoTime valueA, const VuoTime valueB)
 Returns true if the two values are equal. More...
 
bool VuoTime_isLessThan (const VuoTime valueA, const VuoTime valueB)
 Returns true if valueA is less than valueB. More...
 
bool VuoTime_areEqualWithinTolerance (VuoList_VuoTime times, VuoReal tolerance, VuoTimeUnit toleranceUnit)
 Checks if the dates and times are all within a certain distance of each other (within 1 hour, within 8 hours, within 1 year, …). More...
 
bool VuoTime_areTimesOfDayEqualWithinTolerance (VuoList_VuoTime times, VuoReal tolerance, VuoTimeUnit toleranceUnit)
 Checks if the times are all within a certain distance of each other (within 1 minute, within 8 hours, …). More...
 
bool VuoTime_isTimeOfDayLessThan (const VuoTime valueA, const VuoTime valueB, const VuoTime startOfDay)
 Checks if time A is before B, ignoring the date component. More...
 
VuoTime VuoTime_getCurrent (void)
 Returns the current calendar date and time (seconds since 2001.01.01 @ 00:00:00 UTC). More...
 
VuoTime VuoTime_make (VuoInteger year, VuoInteger month, VuoInteger dayOfMonth, VuoInteger hour, VuoInteger minute, VuoReal second)
 Creates a date-time from component values. More...
 
VuoTime VuoTime_makeFromRFC822 (const char *rfc822)
 Creates a date-time from an RFC 822 date-time string. More...
 
VuoTime VuoTime_makeFromISO8601 (const char *iso8601)
 Creates a date-time from an ISO 8601 date-time string. More...
 
VuoTime VuoTime_makeFromUnknownFormat (const char *str)
 Creates a date-time from a string that may have any format of the VuoTimeFormat options, or of VuoTimeFormat_DateTimeShort12, VuoTimeFormat_DateTimeShort24, or VuoTimeFormat_DateShort with 2-digit years instead of 4-digit. More...
 
bool VuoTime_getComponents (VuoTime time, VuoInteger *year, VuoInteger *dayOfYear, VuoInteger *month, VuoInteger *dayOfMonth, VuoInteger *week, VuoWeekday *dayOfWeek, VuoInteger *hour, VuoInteger *minute, VuoReal *second) VuoWarnUnusedResult
 For a given time (in UTC), converts it to the current local timezone, and splits it into its human-readable parts. More...
 
VuoTime VuoTime_round (const VuoTime value, const VuoTimeUnit unit, const int roundingMethod)
 Rounds to a nearby minute, hour, etc. More...
 
VuoText VuoTime_format (const VuoTime time, const VuoTimeFormat format)
 Outputs text containing a date and/or time, in the system's current locale. More...
 
VuoText VuoTime_formatWithLocale (const VuoTime time, const VuoTimeFormat format, const VuoText localeIdentifier)
 Outputs text containing a date and/or time. More...
 
VuoTime VuoTime_makeFromString (const char *str)
 Automatically generated function. More...
 
char * VuoTime_getString (const VuoTime value)
 Automatically generated function. More...
 
void VuoTime_retain (VuoTime value)
 Automatically generated function. More...
 
void VuoTime_release (VuoTime value)
 Automatically generated function. More...
 

Typedef Documentation

◆ VuoTime

typedef double VuoTime

A date and time.

The number of seconds since 2001.01.01 @ 00:00:00 UTC, including fractional seconds.

Regarding precision: A 64-bit double can represent 15 significant figures in decimal. In 2015 (about 441,000,000 seconds since 2001.01.01), that leaves 6 significant figures to represent fractional seconds, meaning VuoTime can represent individual microseconds.

This type is similar in definition to Cocoa's NSDate and Core Foundation's CFDateRef — it's timezone-independent / always in UTC.

Definition at line 45 of file VuoTime.h.

Function Documentation

◆ VuoTime_areEqual()

bool VuoTime_areEqual ( const VuoTime  valueA,
const VuoTime  valueB 
)

Returns true if the two values are equal.

Definition at line 76 of file VuoTime.c.

◆ VuoTime_areEqualWithinTolerance()

bool VuoTime_areEqualWithinTolerance ( VuoList_VuoTime  times,
VuoReal  tolerance,
VuoTimeUnit  toleranceUnit 
)

Checks if the dates and times are all within a certain distance of each other (within 1 hour, within 8 hours, within 1 year, …).

Definition at line 92 of file VuoTime.c.

◆ VuoTime_areTimesOfDayEqualWithinTolerance()

bool VuoTime_areTimesOfDayEqualWithinTolerance ( VuoList_VuoTime  times,
VuoReal  tolerance,
VuoTimeUnit  toleranceUnit 
)

Checks if the times are all within a certain distance of each other (within 1 minute, within 8 hours, …).

Ignores the date components.

Times are considered equal within tolerance if they span midnight. For example, 23:00 and 01:00 are equal within a tolerance of 3 hours.

Definition at line 132 of file VuoTime.c.

◆ VuoTime_format()

VuoText VuoTime_format ( const VuoTime  time,
const VuoTimeFormat  format 
)

Outputs text containing a date and/or time, in the system's current locale.

Uses the current local timezone (except VuoTimeFormat_DateTimeSortable, which is always UTC).

Fractional seconds are rounded down.

Definition at line 628 of file VuoTime.c.

◆ VuoTime_formatWithLocale()

VuoText VuoTime_formatWithLocale ( const VuoTime  time,
const VuoTimeFormat  format,
const VuoText  localeIdentifier 
)

Outputs text containing a date and/or time.

Uses the current local timezone (except VuoTimeFormat_DateTimeSortable, which is always UTC).

Fractional seconds are rounded down.

Definition at line 649 of file VuoTime.c.

◆ VuoTime_getComponents()

bool VuoTime_getComponents ( VuoTime  time,
VuoInteger year,
VuoInteger dayOfYear,
VuoInteger month,
VuoInteger dayOfMonth,
VuoInteger week,
VuoWeekday dayOfWeek,
VuoInteger hour,
VuoInteger minute,
VuoReal second 
)

For a given time (in UTC), converts it to the current local timezone, and splits it into its human-readable parts.

It's OK to pass NULL for any of the output pointers.

Parameters
timeThe time to dissect.
yearMillennium + Century + Decade + Year (e.g., 1970)
dayOfYear1 to 365 or 366
month1 to 12
dayOfMonth1 to 28, 30, or 31
week1 to 52 or 53 (ISO 8601:1988 week number)
dayOfWeek0=Sunday, 1=Monday, …, 6=Saturday
hour0 to 23
minute0 to 59
secondIncludes fractional seconds.
Returns
True if the time could be converted. False for non-times, such as NaN.

Definition at line 435 of file VuoTime.c.

◆ VuoTime_getCurrent()

VuoTime VuoTime_getCurrent ( void  )

Returns the current calendar date and time (seconds since 2001.01.01 @ 00:00:00 UTC).

This function always uses UTC; it does not concern itself with time zones or Daylight Saving Time.

Definition at line 183 of file VuoTime.c.

◆ VuoTime_getJson()

struct json_object* VuoTime_getJson ( const VuoTime  value)

Encodes value as a JSON object.

Definition at line 50 of file VuoTime.c.

◆ VuoTime_getString()

char* VuoTime_getString ( const VuoTime  value)

Automatically generated function.

◆ VuoTime_getSummary()

char* VuoTime_getSummary ( const VuoTime  value)

Returns a compact string representation of value.

Definition at line 58 of file VuoTime.c.

◆ VuoTime_isLessThan()

bool VuoTime_isLessThan ( const VuoTime  valueA,
const VuoTime  valueB 
)

Returns true if valueA is less than valueB.

Definition at line 84 of file VuoTime.c.

◆ VuoTime_isTimeOfDayLessThan()

bool VuoTime_isTimeOfDayLessThan ( const VuoTime  valueA,
const VuoTime  valueB,
const VuoTime  startOfDay 
)

Checks if time A is before B, ignoring the date component.

startOfDay specifies the breakpoint. For example, if startOfDay is 04:00, time 23:00 is considered less than 03:00.

Definition at line 163 of file VuoTime.c.

◆ VuoTime_make()

VuoTime VuoTime_make ( VuoInteger  year,
VuoInteger  month,
VuoInteger  dayOfMonth,
VuoInteger  hour,
VuoInteger  minute,
VuoReal  second 
)

Creates a date-time from component values.

See VuoTime_getComponents for parameter definitions.

Definition at line 205 of file VuoTime.c.

◆ VuoTime_makeFromISO8601()

VuoTime VuoTime_makeFromISO8601 ( const char *  iso8601)

Creates a date-time from an ISO 8601 date-time string.

Example:
2003-12-13T18:30:02Z
Changed in Vuo 2.0.0:
New.

Definition at line 352 of file VuoTime.c.

◆ VuoTime_makeFromJson()

VuoTime VuoTime_makeFromJson ( json_object js)

Decodes the JSON object js to create a new value.

Example:
42.0

Definition at line 42 of file VuoTime.c.

◆ VuoTime_makeFromRFC822()

VuoTime VuoTime_makeFromRFC822 ( const char *  rfc822)

Creates a date-time from an RFC 822 date-time string.

Example:
Fri, 16 Oct 2015 06:42:34 -0400

Definition at line 335 of file VuoTime.c.

◆ VuoTime_makeFromString()

VuoTime VuoTime_makeFromString ( const char *  str)

Automatically generated function.

◆ VuoTime_makeFromUnknownFormat()

VuoTime VuoTime_makeFromUnknownFormat ( const char *  str)

Creates a date-time from a string that may have any format of the VuoTimeFormat options, or of VuoTimeFormat_DateTimeShort12, VuoTimeFormat_DateTimeShort24, or VuoTimeFormat_DateShort with 2-digit years instead of 4-digit.

Definition at line 381 of file VuoTime.c.

◆ VuoTime_release()

void VuoTime_release ( VuoTime  value)

Automatically generated function.

◆ VuoTime_retain()

void VuoTime_retain ( VuoTime  value)

Automatically generated function.

◆ VuoTime_round()

VuoTime VuoTime_round ( const VuoTime  value,
const VuoTimeUnit  unit,
const int  roundingMethod 
)

Rounds to a nearby minute, hour, etc.

Definition at line 475 of file VuoTime.c.