Namespace LrDate

This namespace allows you to create and manipulate date and time values in various formats.

Access the functions directly from the imported namespace.

Summary

Retrieves the current date and time as a Cocoa date stamp; that is, a number of seconds since midnight UTC on January 1, 2001.
LrDate.timeFromComponents( year, month, day, hour, minute, second, timeZone )
Composes a time stamp from the component values.
Converts a timestamp to an ISO formatted date (not including the time).
LrDate.timeToUserFormat( time, format )
Converts a timestamp to a specified date-time format.
Converts a timestamp to a W3C formatted date and time.
Retrieves the current time zone and reports whether that zone is currently observing daylight savings time.
Deprecated: Retrieves the current time zone and reports whether that zone is currently observing daylight savings time.
LrDate.timestampToComponents( time, optTimeZone )
Converts a Cocoa date stamp to its components (i.e.

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.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) The 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.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.timeToUserFormat( time, format )
Converts a timestamp to a specified date-time format. The result is produced with the current user's locale and time zone, which cannot be changed.

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
  • %y: 2-digit year number
  • %Y: 4-digit year number
  • %H: Hour with leading zero (24-hour clock)
  • %I: Hour with leading zero (12-hour clock)
  • %M: Minute with leading zero
  • %S: Second with leading zero
  • %p: AM/PM designation
  • %%: % symbol

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

  1. (number) The offset from UTC in seconds. For example, U.S. Pacific Standard Time (PST) is -28800.
  2. (Boolean) True if daylight savings time is in effect.
LrDate.timeZoneAndDaylightSavingsTime()
Deprecated: Retrieves the current time zone and reports whether that zone is currently observing daylight savings time.

Warning: This function is deprecated as of Lightroom 2.0 and will not be supported in Lightroom 3.0. Use LrDate.timeZone instead.

First supported in version 1.3 of the Lightroom SDK.

Return values

  1. (number) The difference in hours between local time and UTC. Warning: This value is reversed from the typical interpretation of time zone (hours added or subtracted from UTC). For example, U.S. Pacific Standard Time (PST) is +8.0.
  2. (Boolean) True if daylight savings time is in effect.
LrDate.timestampToComponents( time, optTimeZone )
Converts a Cocoa date stamp to its components (i.e. individual values for year, month, day, etc.).

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 0 if not supplied.

Return values

  1. (number) year
  2. (number) month (1-12)
  3. (number) day (1-12)
  4. (number) hour (0-23)
  5. (number) minute (0-59)
  6. (number) second (0-59); fractional seconds may be discarded
  7. (number) day of week (1-7, Sunday = 1, Saturday = 7)