Namespace LrDate
Access the functions directly from the imported namespace.
Summary
Functions
- LrDate.currentTime()
-
Retrieves the current date and time as a Cocoa date stamp; that is, a number of seconds since midnight UTC on January 1, 2001.
First supported in version 1.3 of the Lightroom SDK.
Return value
(number) The current date and time as a Cocoa date stamp value. - LrDate.formatLongDate( time )
-
Converts a timestamp to the user's preferred long date format. The result is produced with the current user's locale and time zone, which cannot be changed in Lightroom. The exact format varies with user preferences and language settings, but is something like "December 31, 2009".
First supported in version 3.0 of the Lightroom SDK.
Parameters
- 1. time
- (number) The Cocoa date stamp; that is, a number of seconds since midnight UTC on January 1, 2001.
Return value
(string) Date in long-date format. - LrDate.formatMediumDate( time )
-
Converts a timestamp to the user's preferred medium date format. The result is produced with the current user's locale and time zone, which cannot be changed in Lightroom. The exact format varies with user preferences and language settings, but is something like "Dec 31, 2009".
First supported in version 3.0 of the Lightroom SDK.
Parameters
- 1. time
- (number) The Cocoa date stamp; that is, a number of seconds since midnight UTC on January 1, 2001.
Return value
(string) Date in medium-date format. - LrDate.formatMediumTime( time )
-
Converts a timestamp to the user's preferred medium time format. The result is produced with the current user's locale and time zone, which cannot be changed in Lightroom. The exact format varies with user preferences and language settings, but is something like "9:12:34 PM".
First supported in version 3.0 of the Lightroom SDK.
Parameters
- 1. time
- (number) The Cocoa date stamp; that is, a number of seconds since midnight UTC on January 1, 2001.
Return value
(string) Time in medium-time format. - LrDate.formatShortDate( time )
-
Converts a timestamp to the user's preferred short date format. The result is produced with the current user's locale and time zone, which cannot be changed in Lightroom. The exact format varies with user preferences and language settings, but is something like "12/31/09".
First supported in version 3.0 of the Lightroom SDK.
Parameters
- 1. time
- (number) The Cocoa date stamp; that is, a number of seconds since midnight UTC on January 1, 2001.
Return value
(string) Date in short-date format. - LrDate.formatShortTime( time )
-
Converts a timestamp to the user's preferred short time format. The result is produced with the current user's locale and time zone, which cannot be changed in Lightroom. The exact format varies with user preferences and language settings, but is something like "9:12 PM".
First supported in version 3.0 of the Lightroom SDK.
Parameters
- 1. time
- (number) The Cocoa date stamp; that is, a number of seconds since midnight UTC on January 1, 2001.
Return value
(string) Time in short-time format. - LrDate.timeFromComponents( year, month, day, hour, minute, second, timeZone )
-
Composes a time stamp from the component values.
First supported in version 1.3 of the Lightroom SDK.
Parameters
- 1. year
- (number) The 4-digit year.
- 2. month
- (number) The month, in the range [1..12]
- 3. day
- (number) The day, in the range [1..31]
- 4. hour
- (number) The hour, in the range [0..23]
- 5. minute
- (number) The minute, in the range [0..59]
- 6. second
- (number) The second, in the range [0..59]
- 7. timeZone
- (number, string, Boolean) The string "local" or true to use the local time zone, or an explicit time zone, expressed as the difference in seconds from UTC. For example, U.S. Pacific Standard Time is -28800. Warning: The 1.3 SDK documentation incorrectly stated that the timeZone parameter was expressed in hours relative to UTC.
Return value
(number) The time as a Cocoa date stamp; that is, a number of seconds since midnight UTC on January 1, 2001. - LrDate.timeFromPosixDate( time )
-
Converts a Unix/Posix-style date timestamp to a Mac-style timestamp.
First supported in version 3.0 of the Lightroom SDK.
Parameters
- 1. time
- (number) The Unix/Posix date stamp; that is, a number of seconds since midnight UTC on January 1, 1970
Return value
(number) The Cocoa date stamp; that is, a number of seconds since midnight UTC on January 1, 2001 - LrDate.timeToIsoDate( time )
-
Converts a timestamp to an ISO formatted date (not including the time).
First supported in version 1.3 of the Lightroom SDK.
Parameters
- 1. time
- (number) The Cocoa date stamp; that is, a number of seconds since midnight UTC on January 1, 2001.
Return value
(string) An ISO formatted date string (such as "2007-10-06"). - LrDate.timeToPosixDate( time )
-
Converts a Mac-style timestamp to a Unix/Posix-style date timestamp.
First supported in version 3.0 of the Lightroom SDK.
Parameters
- 1. time
- (number) The Cocoa date stamp; that is, a number of seconds since midnight UTC on January 1, 2001
Return value
(number) The Unix/Posix date stamp; that is, a number of seconds since midnight UTC on January 1, 1970 - LrDate.timeToUserFormat( time, format, isGMT )
-
Converts a timestamp to a specified date-time format. The result is produced with the current user's locale, which cannot be changed. By default the result applies the local timezone.
First supported in version 1.3 of the Lightroom SDK.
Parameters
- 1. time
- (number) The Cocoa date stamp; that is, a number of seconds since midnight UTC on January 1, 2001.
- 2. format
- (string) The date-time format string. Use the following special strings for date elements:
- %B: Full name of month
- %b: 3-letter name of month
- %m: 2-digit month number
- %d: Day number with leading zero
- %e: Day number without leading zero
- %j: Julian day of the year with leading zero
- %a: Day name abbreviation
- %A: Day name
- %y: 2-digit year number
- %Y: 4-digit year number
- %H: Hour with leading zero (24-hour clock)
- %1H: Hour without leading zero (24-hour clock)
- %I: Hour with leading zero (12-hour clock)
- %1I: Hour without leading zero (12-hour clock)
- %M: Minute with leading zero
- %S: Second with leading zero
- %p: AM/PM designation
- %P: AM/PM designation, same as %p,but causes white space trimming to be applied as the last formatting step.
- %%: % symbol
- 3. isGMT
- (boolean) If true, use GMT rather than the local timezone when converting to the user format.
Return value
(string) The formatted date-time string. - LrDate.timeToW3CDate( time )
-
Converts a timestamp to a W3C formatted date and time.
First supported in version 1.3 of the Lightroom SDK.
Parameters
- 1. time
- (number) The Cocoa date stamp; that is, a number of seconds since midnight UTC on January 1, 2001.
Return value
(string) A W3C formatted date-time string (such as "2007-10-06T12:54:39-07:00"). - LrDate.timeZone()
-
Retrieves the current time zone and reports whether that zone is currently observing daylight savings time.
First supported in version 2.0 of the Lightroom SDK.
Return values
- (number) The offset from UTC in seconds. For example, U.S. Pacific Standard Time (PST) is -28800.
- (Boolean) True if daylight savings time is in effect.
- LrDate.timestampToComponents( time, optTimeZone )
-
Converts a Cocoa date stamp to its components (that is, individual values for year, month, day, and so on).
First supported in version 2.0 of the Lightroom SDK.
Parameters
- 1. time
- (number) The date and time as a Cocoa date stamp value (i.e. number of seconds since midnight UTC on January 1, 2001).
- 2. optTimeZone
- (number) An optional time zone bias to apply to the date stamp before conversion, expressed as a number of seconds relative to UTC (i.e. US Central Standard Time would be -21600). Defaults to local time zone if not supplied.
Return values
- (number) year
- (number) month (1-12)
- (number) day (1-12)
- (number) hour (0-23)
- (number) minute (0-59)
- (number) second (0-59); fractional seconds may be discarded
- (number) day of week (1-7, Sunday = 1, Saturday = 7)