Vuo  2.3.2
Functions | Variables
VuoTime.c File Reference

Description

VuoTime implementation.

Definition in file VuoTime.c.

Go to the source code of this file.

Functions

VuoTime VuoTime_makeFromJson (json_object *js)
 Decodes the JSON object js to create a new value. More...
 
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...
 
VuoTime VuoTime_removeDate (const VuoTime time)
 Removes the date component, so the time is relative to 2001.01.01. 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...
 
static bool VuoTime_isLeapYear (VuoInteger year)
 Returns true if the specified year is a Gregorian leap year. More...
 
VuoTime VuoTime_make (VuoInteger year, VuoInteger month, VuoInteger dayOfMonth, VuoInteger hour, VuoInteger minute, VuoReal second)
 Creates a date-time from component values. More...
 
static char * VuoTime_stringForFormat (VuoTimeFormat format, locale_t locale)
 Returns a format string. More...
 
static VuoTime VuoTime_makeFromFormats (const char *str, const char **formats, int numFormats)
 Creates a date-time from a string — trying to parse it with the first of formats; if that fails, trying the second of formats; and so on. 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...
 
static char * VuoTime_changeTo2DigitYear (char *format)
 In a strftime/strptime time format, changes 4-digit years to 2 digits. 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)
 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...
 

Variables

const int VuoUnixTimeOffset = (31 * 365 + 8 ) * 24 * 60 * 60
 The difference between the Unix epoch and the Mac (and Vuo) epoch. More...
 

Function Documentation

◆ VuoTime_changeTo2DigitYear()

static char* VuoTime_changeTo2DigitYear ( char *  format)
static

In a strftime/strptime time format, changes 4-digit years to 2 digits.

Definition at line 369 of file VuoTime.c.

◆ VuoTime_isLeapYear()

static bool VuoTime_isLeapYear ( VuoInteger  year)
static

Returns true if the specified year is a Gregorian leap year.

Definition at line 194 of file VuoTime.c.

◆ VuoTime_makeFromFormats()

static VuoTime VuoTime_makeFromFormats ( const char *  str,
const char **  formats,
int  numFormats 
)
static

Creates a date-time from a string — trying to parse it with the first of formats; if that fails, trying the second of formats; and so on.

This function only considers a format to have successfully parsed the string if the format applies to the entire string (not including trailing whitespace).

Definition at line 300 of file VuoTime.c.

◆ VuoTime_removeDate()

VuoTime VuoTime_removeDate ( const VuoTime  time)

Removes the date component, so the time is relative to 2001.01.01.

Definition at line 120 of file VuoTime.c.

◆ VuoTime_stringForFormat()

static char* VuoTime_stringForFormat ( VuoTimeFormat  format,
locale_t  locale 
)
static

Returns a format string.

Some formats depend on locale, some don't.

Definition at line 259 of file VuoTime.c.

Variable Documentation

◆ VuoUnixTimeOffset

const int VuoUnixTimeOffset = (31 * 365 + 8 ) * 24 * 60 * 60

The difference between the Unix epoch and the Mac (and Vuo) epoch.

Definition at line 177 of file VuoTime.c.