Star Trek

A sci-fi TV show, later turned into a long movie sequel.

Mentioned here for some obscure reason. Maybe they used Tcl in the Enterprise... turns out that Tcl's [clock scan] supports Star Trek's stardate notation:

 % clock scan "stardate 20 . 20"

I've no idea who added this or why. I cannot see it in the documentation either. Strikes me as needless code bloat. Does *anyone* use this?

sergiol The author confesses himself on

RS Also:

 43258 % clock format [clock sec] -format %Q
 Stardate 57824.5

RJ further embarasses himself by adding that the above Next Generation stardate is actually the stardate for the current date in the 24th century. For some reason, the author chose to do this. The "57" refers to 57 years since the base year 2323 (known as year zero.) The current stardate would be a negative value otherwise. Jeez, I hate that I know this.

TK Version:

 #!/usr/bin/env wish

 # see:

 package require Tk

 proc sleep {time} {
     global end
     after $time set end 1
     vwait end

 proc setTime {} {
     global time clicks
     set time [clock format [clock sec] -format %Q]
     set current [clock format [clock sec] -format {-%m-%d %H:%M:%S}]
     set year [expr [clock format [clock sec] -format {%Y}] + 377]
     set clicks $year$current 


 label .l -textvariable time
 label .m -textvariable clicks
 pack .l
 pack .m

 while {true} {
     sleep 1000

The source for "strftime.c" reveals that the undocumented %Q format specifier is done as a special case:

    /* ... from strftime.c ... */
    if (format[0] == '%' && format[1] == 'Q') {
        /* Format as a stardate */
        sprintf(s, "Stardate %2d%03d.%01d",
                (((t->tm_year + TM_YEAR_BASE) + 377) - 2323),
                (((t->tm_yday + 1) * 1000) /
                        (365 + IsLeapYear((t->tm_year + TM_YEAR_BASE)))),
                (((t->tm_hour * 60) + t->tm_min)/144));
    /* ... */

 (bin) 50 % clock format [clock sec] -format "%Q blah"
 Stardate 57547.3
 (bin) 51 % clock format [clock sec] -format " %Q blah"
  Q blah

Anyone know who/when/why introduced this curious feature?

Just before the Tcl/2k conference in Austin - ask Jeff Hobbs and/or Kevin Kenny...

Ro: This is really neat ;)

I believe the option was named %Q because of the Star Trek Next Generation recurring character of Q of the Q Consortium...

AMG thinks it's actually the Q Continuum.

"My name's Q. That's short for Q."

Maybe it was in honour of Scotty:

What is Scotty? Scotty is the name for a software package which allows to implement site specific network management software using high-level, string-based APIs. The software is based on the Tool Command Language (Tcl) which simplifies the development of portable network management applications. The scotty source distribution includes two components: The Tnm Tcl extension allows to access network management information. The Tkined network editor provides a framework for an extensible network management platform.

What is the story behind the name Scotty? Some people say it has something to do with the startrek series. Scotty was the character who had to make the impossible possible in order to keep the starship flying and the scotty package may do the same for your network. Others say that this name happened by accident because the author of the Scotty package was just too lazy to come up with a better name...

Or maybe it was in honor of George Takei, pronounced "Tk," who played Sulu on Star Trek.

LES: Although the %Q option works in 8.4, it is not documented in 8.4. It is documented in 8.5, but the text sort of dodges the issue: "This format group is reserved for internal use within the Tcl library." In other words, "we acknowledge the existence, but don't feel like talking about it."

KBK: To quote Beauregard Claghorn[L1 ]: "It's a joke, son! Joke, that is. Pay attention son! (Kid's about as smart as a bag full o'wet mice)." The idea at the time was that Tcl was being pitched as "Enterprise Ready."


DG: Beauregard? Your quote rang out more like Foghorn Leghorn[L2 ] to me ;) "A chicken hawk, eh? Over there's your chicken."

escargo 19 Sep 2005 - I added Wikipedia[L3 ] links to Claghorn and Foghorn above. The Wikipedia entries mentioned the irony of Foghorn remaining known, and Claghorn (the original being spoofed) becoming lost in the mists of time. It's probably not the only case in cartoon history.

etdxc This is another of those features that make me love the language. I used to love to find this sort of thing in Unix termcaps. I need therapy.

MrStonedOne: as far as i can tell its the time since Tue May 12 00:00:00 GMT 1835 in the format of

(days).(time in the format of tenths of a day):

clock format clock sec -format %Q (Stardate 63665.1)

clock scan "63665 days ago" -gmt 1(-4248892800)

clock format -4248892800 -gmt 1(Tue May 12 00:00:00 GMT 1835)

Does anyone know anything that happened on that date that relates to a programmer or star trek or scifi?

LV While I don't know the answer to this question, I did run across while googling the subject of calculating stardates similar to the Trek universe.

al - 2009-09-07 01:18:14

Apparently, a letter dated April 27, 1835 from Charles Babbage to Adolphe Quetelet has been identified as the earliest known reference to the Analytical Engine. One may speculate that Quetelet received the letter in May?

This may be merely coincidental.

RKzn - Stardate 69580.0 2015-08-01 The reference year is 1946:

% clock format [clock scan {1946-01-01 00:00}] -format %Q
Stardate 00000.0

The Stardate does not count days, as far as I can see it uses a couple of ideas from the series, plus 1946 as reference, I do not know why. The date format, right to left seems to be:

The digit after the (decimal) point is the one thing that seems to remain well defined through out the series. «Each percentage point is roughly equivalent to one-tenth of one day», «The digit following the decimal point is generally regarded as a day counter.», i.e., the last digit is completed tenths of a day (02:24), so

% clock format [clock scan {1946-01-01 02:23}] -format %Q
Stardate 00000.0
% clock format [clock scan {1946-01-01 02:24}] -format %Q
Stardate 00000.1
% clock format [clock scan {1946-01-01 04:47}] -format %Q
Stardate 00000.1
% clock format [clock scan {1946-01-01 04:48}] -format %Q
Stardate 00000.2

Digits to the left of the point seem to have had just about anything, including intentionally almost random numbers: «Pick any combination of four numbers plus a percentage point, use it as your story's stardate.... don't worry about whether or not there is a progression from other scripts». One computable standard was a «system by having a calendar year start at 000 and end at 999 ... 41xxx.x covered the entire year 2364, stardates 42xxx.x the entire year 2365 and so forth.» Thus, each day results in jumping 3 or 2 units in the Stardate (1 day ~ 1/365 year ~ 2.7 thousandth of a year)

% clock format [clock scan {1946-01-01 00:00}] -format %Q
Stardate 00000.0
% clock format [clock scan {1946-01-02 00:00}] -format %Q
Stardate 00002.0
% clock format [clock scan {1946-01-03 00:00}] -format %Q
Stardate 00005.0
% clock format [clock scan {1946-01-04 00:00}] -format %Q
Stardate 00008.0

The same previous quote places the reference year on 2323, as said above. Why switching to 1946? Making present day dates a positive number makes sense; signing with "Stardate 69580.0" is nicer than "Stardate -308580.0", I'd say. Why 1946...?

All quotes from: Stardate, from Memory-alpha , also interesting: How do stardates work?, at