Jump to content

Celestia/Celx Scripting/CELX Lua Methods/CEL command time

From Wikibooks, open books for an open world

time { jd <juliandatenumber> }

-- OR --

time { utc <string> }

Sets the Date and Time using a Julian Date (a decimal number) or a UTC time string, in the format YYYY-MM-DDTHH:MM:SS.SSSSS.

Arguments:

jd <juliandatenumber>
A valid Julian date. No default.

-- OR --

Arguments:

utc <string>
A valid date in UTC format: YYYY-MM-DDTHH:MM:SS.SSSSS. No default.

Note: To obtain a Julian Date from a normal calendar date, try the U.S. Navy Calendar Date/Time to Julian Date/Time converter, located at: Julian Date Converter.

Note: Within Celestia it is also possible to obtain a Julian Date from a normal calendar date. Select the "Time" option in the menu bar. Next select the option "Set Time …" after which a "Set Simulation Time" window will be displayed. This window contains both Time formats and can be used to convert Julian Date/Time to UTC Date/Time and vice versa.


CELX equivalents:

Based on the celestia:settime() method and some date/time conversion methods.

Starting with version 1.5.0, although Celestia still displays UTC on the screen, it uses the TDB time scale internally for everything else, so for CELX scripting !!!

  1. For these newer Celestia versions, using the UTC Julian date (as a result of the celestia:tojulianday() method) in the celestia:settime() method, will cause the WRONG setting of the simutation time. To set the simulation time, using Julian date for these newer Celestia versions, the 1.5.0 celestia:utctotdb() method should be used instead.
  2. For these newer Celestia versions, using the celestia:gettime() method to obtain a Julian date, and convert that to a Calender date/time with this celestia:fromjulianday() method, will cause to obtain the WRONG Calender date/time. To obtain the right Calender date/time, using the Julian date from the celestia:gettime() method, for these newer Celestia versions, the 1.5.0 celestia:tdbtoutc() method should be used instead.
  3. For more information on TDB, UTC, and how time is used in Celestia, see Time Scales.


To convert between Calender date and Julian date, UTC and TDB, the following Celestia methods can be used:

  • Celestia version 1.4.1 and older.
    Convert a UTC calendar date to a UTC Julian date and set simulation date/time. If not specified:
    • <monthnumber> and <daynumber> default to one
    • <hournumber>, <minutenumber> and <secondnumber> default to zero.
juliandate = celestia:tojulianday( <yearnumber>, <monthnumber>, <daynumber>,
                                   <hournumber>, <minutenumber>, <secondnumber> )
celestia:settime(juliandate)
  • Celestia version 1.4.1 and older.
    Get simulation date/time and convert a UTC Julian date to a UTC calendar date.
    The returned table "utctable" contains the keys:
    • utctable.year = <yearnumber>
    • utctable.month = <monthnumber>
    • utctable.day = <daynumber>
    • utctable.hour = <hournumber>
    • utctable.minute = <minutenumber>
    • utctable.seconds = <secondnumber>
juliandate = celestia:gettime()
utctable = celestia:fromjulianday(juliandate)
  • Celestia version 1.5.0 and newer.
    Convert a UTC calendar date to a TDB Julian date and set simulation date/time.If not specified:
    • <monthnumber> and <daynumber> default to one
    • <hournumber>, <minutenumber> and <secondnumber> default to zero.
tdbdate = celestia:utctotdb( <yearnumber>, <monthnumber>, <daynumber>, 
                             <hournumber>, <minutenumber>, <secondnumber> )
celestia:settime(tdbdate)
  • Celestia version 1.5.0 and newer.
    Get simulation date/time and convert a TDB Julian date to a UTC calendar date.
    The returned table "utctable" contains the keys:
    • utctable.year = <yearnumber>
    • utctable.month = <monthnumber>
    • utctable.day = <daynumber>
    • utctable.hour = <hournumber>
    • utctable.minute = <minutenumber>
    • utctable.seconds = <secondnumber>
tdbdate = celestia:gettime()
utctable = celestia:tdbtoutc(tdbdate)


Example:
Examples of how to set the date and time to August 11, 2003 at 9:29:24 UTC.

CEL:

time { jd 2452862.89542 }

...

time { utc "2003-08-11T09:29:24.0000" }

CELX Celestia version 1.4.1 and older:

celestia:settime(2452862.89542)

...

juliandate = celestia:tojulianday(2003, 08, 11, 09, 29, 24.0000)
celestia:settime(juliandate)

CELX Celestia version 1.5.0 and newer:

utctable = celestia:fromjulianday(2452862.89542)
tdbdate = celestia:utctotdb(utctable.year, utctable.month, utctable.day,
                            utctable.hour, utctable.minute,utctable.seconds)
celestia:settime(tdbdate)

...

tdbdate = celestia:utctotdb(2003, 08, 11, 09, 29, 24.0000 )
celestia:settime(tdbdate)


Back to CEL command index