Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A quick fix for negative dates #1

Merged
merged 1 commit into from
Nov 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions Christmas_Star_10-11-23.ssc
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ waitNextStep();

////////////////////////////////////////////////////////////////////////////////////////
//
// STEP 3 - ALL CONSTELLATIONS FADE, ANNUAL MOTION FORWARD UNTIL MORNING OF 01 JUN 2 BC.
// STEP 3 - ALL CONSTELLATIONS FADE, ANNUAL MOTION FORWARD UNTIL MORNING OF 12 FEB 2 BC.
//


Expand Down Expand Up @@ -249,10 +249,15 @@ waitNextStep();
// ANNUAL MOTION TO 01 JUNE 2 BC

function formatDate(dateString) {
var idx = 0;
if (dateString.slice(0, 1)=='-') {
idx = 1;
}
var dateParts = dateString.split("-");
var year = parseInt(dateParts[0]);
var month = parseInt(dateParts[1]);
var day = parseInt(dateParts[2]);
var year = parseInt(dateParts[idx]);
if (idx==1) { year *= -1; }
var month = parseInt(dateParts[idx+1]);
var day = parseInt(dateParts[idx+2]);

var monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
var formattedMonth = monthNames[month - 1];
Expand Down Expand Up @@ -281,7 +286,12 @@ var targetJDay = 1720843.58976; // Julian Day for 01 June 2 BC

while (core.getJDay() < targetJDay) {
core.setDate("+2 days"); // Increment the date by two days
var currentDate = core.getDate("utc").toString().slice(0, 10); // Get the current date as a string in the format "YYYY-MM-DD"
var currentDateTime = core.getDate("utc").toString();
var depth = 10;
if (currentDateTime.slice(0, 1)=='-') {
depth = 11;
}
var currentDate = core.getDate("utc").toString().slice(0, depth); // Get the current date as a string in the format "YYYY-MM-DD"
var formattedDate = formatDate(currentDate); // Format the date to the desired format "DD Month YYYY BC/AD"
LabelMgr.deleteLabel(labelID); // Delete the old label
labelID = LabelMgr.labelHorizon(formattedDate, 160, 10, true, 30, "#ff0000"); // Create a new label with the updated date and store its ID
Expand Down Expand Up @@ -384,4 +394,4 @@ ConstellationMgr.setFlagIsolateSelected(false);
ConstellationMgr.selectAllConstellations();
core.wait(0.1);
core.setTimeRate(200);
//core.setGuiVisible(true);
//core.setGuiVisible(true);