Do you have a better solution how to convert today's dates to Stardate? Is there any agreed on (by fans, anyways) standard that I simply missed?
Do you have a better solution how to convert today's dates to Stardate? Is there any agreed on (by fans, anyways) standard that I simply missed?
Oooh, neat question! I remember pondering this when I was a teenager in the 90s.
I actually realized early on that the standard ISO date format is the best: YYYY-MM-DD (although I didn't use hyphens at the time, as stardates don't have hyphens), and started using YYYYMMDD for my digital diary way back then (long lost, sadly, or maybe not SO sadly, if you knew me as a teenager, lol)
But the canonical system of #Stardate as of the TNG era was 40000 + 1000 * season_number + "day", where the "day" was something like (day_of_year / 365 * 999)
So, since season 1 was 1987, the "current" stardate would be something like 2025-1987 + 41 = 79000
As far as the non-sequential order of TOS stardates goes, this is because NBC did not air the episode in the order they were made. They were produced sequentially, but not aired sequentially.
The other problem is that the stardates are tied to the beginning of TNG seasons (in the fall), and not the beginning of calendar years. That makes things more difficult, but I guess the best solution would be to use the number of days since Encounter at Farpoint aired? (1987-09-28)
Here's what I came up with using bash, bc (which you may need to install) and awk:
$ echo "( $(date +%s) - $(date +%s -d 1987-09-28) ) / 365.25 / 24 / 3600 * 1000 + 41000" |bc -l |awk '{printf "%.1f\n", $1}'
78967.2
@mirabilos @nazgul @amin @bugbear
How do you set the decimal precision without -l? I'm a total noob.
@rl_dane @nazgul @amin @bugbear -l just loads the library (for sinus, etc). You need set the scale, even if you load the library.
RTFM bc(1), dc(1), 06.bc(USD), 05.dc(USD)
@mirabilos @rl_dane @nazgul @bugbear
Yeah, I just couldn't resist the reference; I don't get to cite that one often. ;)
@mirabilos @rl_dane @nazgul @bugbear
Neither do I get to cite my favorite xkcd strip very often: https://xkcd.com/585/
@rl_dane @amin @nazgul @bugbear (though I just noticed that itās apparently normal that loading the math lib sets the scale to 20)
As to the original problem:
# inlining 559785600=$(date +%s -ud 1987-09-28)
# to stay portable to systems without GNU date
printf '%s\n' \
'scale=9' \
"v=($(date +%s) - 559785600) * 1000 / 60 / 60 / 24 / 365.2425" \
scale=1 '(v+.05)/1' | bc
This even solves the rounding, no need to awk around.
Tbh itās ugly, and Iād rather just define the generic-correct bc rounding function first, then just use it:
bc <<EOF
define r(x,n) {
auto o
o = scale
if (scale < (n + 1)) scale = (n + 1);
/* assume sign is positive instead of getting the sign first
x += v(x) * 0.5 * A^-n
*/ x += 0.5 * A^-n
scale = n
x /= 1
/* drop trailing zeroes */
/* commented out for this use case
for (scale = 0; scale <= o; scale++) {
if (x == x/1) {
x /= 1
break
}
}
*/
scale = o
return (x)
}
scale=9
r(($(date +%s) - 559785600) * 1000 / 60 / 60 / 24 / 365.2425, 1)
EOF
I commented out stuff that requires use of a separate function to get the signā¦
define v(x) {
if (x < 0) return (-1)
if (x > 0) return (1)
return (0)
}
⦠and that removes trailing 0s at the end asuming you always want d+.d precision for your āstar datesā.
@mirabilos @amin @nazgul @bugbear
That is... a lot more complex than just calling bc -l ;)
@mirabilos @amin @nazgul @bugbear
I'm willing to call another fork() for the sake of simplicity, especially when it's not in a loop.
@mirabilos @bugbear @nazgul @amin
I mean, it's a full programming language in its own right, of course, and I'm using it in probably the dumbest way, but for all its internal complexity, it performs this one simple job very well.
ĀÆ\_(ć)_/ĀÆ
@samd @rl_dane @mirabilos @nazgul @bugbear
Well in theory at least the response could evoke a change in behavior that prevents future interruptions of this nature.
@mirabilos @nantucketlit @amin @nazgul @bugbear
Not dead, "dood" (dude). ;)
@mirabilos @nantucketlit @amin @nazgul @bugbear
Ahhh... Well, the internet says that [dutch is not a serious language] ;)
@mirabilos @nantucketlit @amin @nazgul @bugbear
I still hear Dutch speakers as "this is what American English would sound like to me if I didn't know English, but with an occasional "kh" sound" ;)
@amin @nazgul @rl_dane @bugbear @nantucketlit it varies a lot; the "barok" radio Iām currently listening toās moderation consists almost wholly of throat sounds with an occasional comprehensible word or two thrown in.
I learn languages by reading/writing, which makes this⦠challenging.
@mirabilos @amin @nazgul @bugbear @nantucketlit
> I learn languages by reading/writing, which makes this⦠challenging.
I've often wondered if Korean couldn't be the easiest Asian language to learn, as its writing system (Hangul) is very easy to learn.
@amin @rl_dane @bugbear @nazgul @nantucketlit lots and lots of homoglyphs due to the history of ideographs.
Cymraeg seems nice. No silent letters like Gaelic, and the pronunciation (once you get w and y sorted and remember u is i) is totally straightforward, with a bit of difference between N/S Wales.
@mirabilos @amin @bugbear @nazgul @nantucketlit
That's interesting! I once saw an experiment of mutual intelligibility on YT between a Welsh and Irish (I think) Gaelic speaker, and it was pretty fascinating.
The two languages did sound similar to my (completely untrained) ears, but they had a lot of difficulty understanding each other. As I recall, they had a lot of shared cognates, but not so much a 1:1 between words.
@rl_dane @mirabilos @nantucketlit @amin @nazgul @bugbear
Dutch is like if a german and english got into a carcrash, and then you throw in half of a scandinav in there for some extra spice, it's a really funny language for me, and kind of annoying, because I can halfway understand it if I focus, and otherwise it's just weird gibberish.
@sotolf @amin @rl_dane @nantucketlit @nazgul @bugbear thereās also lots of variety, even if you exclude honestly different languages like Limburgish, flames from the east and west side of Belgium speak with each other in English because their Dutch variants are not sufficiently mutually intellegibleā¦
Belgium is like three hours by car or high-speed train wide.
@mirabilos @amin @rl_dane @nantucketlit @nazgul @bugbear
I've only actually been in Belgium, but I find it kind of hard to believe that they are that inflexible, we have about ~400 or so Norwegian dialects with differences in everything, grammar, words, tone difference, accent, and so on, to the point that some swedish dialects for example are easier for me to understand than the ones of my country men, but we don't really do the english thing, because even with Norwegian which doesn't have a standard spoken language, you usually end up slowly approximating each other until you get to a middle point where both parts understand.
I mean unless they just are too lazy to actually try that is :p
@mirabilos @amin @rl_dane @nantucketlit @nazgul @bugbear
But then I don't really envy people wanting to learn the language when I look at some conjugation tables, here are the most common but not all, personal pronouns and possessive pronouns in common use:
@sotolf @mirabilos @amin @nantucketlit @nazgul @bugbear
That reminds me of this gem... XD
@rl_dane @sotolf @mirabilos @nantucketlit @nazgul @bugbear
Heh, Iāve seen this. A highschool friend of mine loved these comics. Drew some of his own, too.
@amin @sotolf @mirabilos @nantucketlit @nazgul @bugbear
I think I saw it nearly 10 years ago, so sounds about right. ;)
EDIT: this is erroneous, see correction later in thread
If you want to evade bc you can do this in pure awk (and the bash date, dealing with dates in awk is not fun) like this
echo '' | awk -v season="$(date +%s) - $(date +%s -d 1987-09-28)" '{printf "%.1f\n", season / 365.25 / 24 / 3600 * 1000 + 41000}'
EDIT: this is erroneous, see correction later in thread
Actually this also works because awk just throw away what you pipe into it here, it's just there to not loop it over stdin really.
1 | awk -v season="$(date +%s) - $(date +%s -d 1987-09-28)" '{printf "%.1f\n", season / 365.25 / 24 / 3600 * 1000 + 41000}'