Lightroom SDK: LrDate.timestampToComponents - support julian day.

  • 1
  • Idea
  • Updated 5 years ago
Julian day component would be useful to have in some cases. It's not a big deal, but still, if you're in there, why not?

Bonus idea:
--------------
* Don't discard fractional seconds.
Photo of Rob Cole

Rob Cole

  • 4831 Posts
  • 372 Reply Likes

Posted 5 years ago

  • 1
Photo of Rob Cole

Rob Cole

  • 4831 Posts
  • 372 Reply Likes
Present workaround:

--- Format time as structure with named members (numerical values).
--
function DateTime:timeStruct( dt, ofs, includeJulianDay )
local timeNumArray = { LrDate.timestampToComponents( dt, ofs ) } -- nil => local time-zone, 0 => utc/gmt.
local timeNumStruct = {
year = timeNumArray[1],
month = timeNumArray[2],
day = timeNumArray[3],
hour = timeNumArray[4],
minute = timeNumArray[5],
second = timeNumArray[6],
-- reminder: fractional seconds *may* be discarded.
dayOfWeek = timeNumArray[7],
-- note: no julian day.
}
if includeJulianDay then
local js = LrDate.timeToUserFormat( dt, "%j", ofs ~= nil ) -- is-gmt.
timeNumStruct.julianDay = num:numberFromString( js )
end
return timeNumStruct
end