@@ -44,6 +44,24 @@ let updateInterval;
let lastRenderedEonstrip = null ;
let lastRenderedEonstrip = null ;
let currentDetailCob = null ;
let currentDetailCob = null ;
function getTimezoneOffsetSeconds ( date ) {
if ( currentTimezone === 'UTC' ) return 0 ;
if ( currentTimezone === 'TAI' ) return getTAIOffsetAt ( date ) ;
const dtf = new Intl . DateTimeFormat ( 'en-US' , {
timeZone : currentTimezone ,
year : 'numeric' , month : '2-digit' , day : '2-digit' ,
hour : '2-digit' , minute : '2-digit' , second : '2-digit' ,
hour12 : false
} ) ;
const parts = dtf . formatToParts ( date ) . reduce ( ( acc , p ) => {
if ( p . type !== 'literal' ) acc [ p . type ] = parseInt ( p . value , 10 ) ;
return acc ;
} , { } ) ;
const utcTime = Date . UTC ( parts . year , parts . month - 1 , parts . day ,
parts . hour , parts . minute , parts . second ) ;
return ( utcTime - date . getTime ( ) ) / 1000 ;
}
function formatSafeDate ( rawDate , cobSeconds , intlOptions ) {
function formatSafeDate ( rawDate , cobSeconds , intlOptions ) {
if ( rawDate instanceof Date && ! isNaN ( rawDate . getTime ( ) ) ) {
if ( rawDate instanceof Date && ! isNaN ( rawDate . getTime ( ) ) ) {
// Date is valid: optionally shift for TAI vs UTC, then format:
// Date is valid: optionally shift for TAI vs UTC, then format:
@@ -607,9 +625,11 @@ function updateCalendar() {
const cellEnd = cellCob + COBIE _UNITS . eonstrip ;
const cellEnd = cellCob + COBIE _UNITS . eonstrip ;
window . SPECIAL _EVENTS . forEach ( ev => {
window . SPECIAL _EVENTS . forEach ( ev => {
if ( ev . showMega === false ) return ;
if ( ev . showMega === false ) return ;
const startCob = parseCobiets ( ev . start || ev . cobie ) ;
const baseStart = parseCobiets ( ev . start || ev . cobie ) ;
if ( startCob === null ) return ;
if ( baseStart === null ) return ;
const endCob = ev . end ? parseCobiets ( ev . end ) : Number . POSITIVE _INFINITY ;
const tzShift = ev . shiftWithTimezone ? getTimezoneOffsetSeconds ( fromCobiets ( baseStart ) ) : 0 ;
const startCob = baseStart - tzShift ;
const endCob = ev . end ? parseCobiets ( ev . end ) - tzShift : Number . POSITIVE _INFINITY ;
const unitVal = COBIE _UNITS [ ev . unit ] || COBIE _UNITS . cosmocycle ;
const unitVal = COBIE _UNITS [ ev . unit ] || COBIE _UNITS . cosmocycle ;
const interval = ( ev . interval || 1 ) * unitVal ;
const interval = ( ev . interval || 1 ) * unitVal ;
let duration = 0 ;
let duration = 0 ;
@@ -714,9 +734,11 @@ function showEonstripDetail(index, startCob) {
const end = startCob + COBIE _UNITS . eonstrip ;
const end = startCob + COBIE _UNITS . eonstrip ;
window . SPECIAL _EVENTS . forEach ( ev => {
window . SPECIAL _EVENTS . forEach ( ev => {
if ( ev . showDetail === false ) return ;
if ( ev . showDetail === false ) return ;
const startCobEv = parseCobiets ( ev . start || ev . cobie ) ;
const baseStart = parseCobiets ( ev . start || ev . cobie ) ;
if ( startCobEv === null ) return ;
if ( baseStart === null ) return ;
const endCobEv = ev . end ? parseCobiets ( ev . end ) : Number . POSITIVE _INFINITY ;
const tzShift = ev . shiftWithTimezone ? getTimezoneOffsetSeconds ( fromCobiets ( baseStart ) ) : 0 ;
const startCobEv = baseStart - tzShift ;
const endCobEv = ev . end ? parseCobiets ( ev . end ) - tzShift : Number . POSITIVE _INFINITY ;
const unitVal = COBIE _UNITS [ ev . unit ] || COBIE _UNITS . cosmocycle ;
const unitVal = COBIE _UNITS [ ev . unit ] || COBIE _UNITS . cosmocycle ;
const interval = ( ev . interval || 1 ) * unitVal ;
const interval = ( ev . interval || 1 ) * unitVal ;
let duration = 0 ;
let duration = 0 ;
@@ -742,7 +764,9 @@ function showEonstripDetail(index, startCob) {
start : relStart ,
start : relStart ,
end : relEnd ,
end : relEnd ,
cobStart : occ ,
cobStart : occ ,
cobEnd : occ + duration
cobEnd : occ + duration ,
seriesStart : startCobEv ,
seriesEnd : endCobEv
} ) ;
} ) ;
occ += interval ;
occ += interval ;
}
}
@@ -791,21 +815,25 @@ function showEonstripDetail(index, startCob) {
const tooltip = document . createElement ( 'div' ) ;
const tooltip = document . createElement ( 'div' ) ;
tooltip . className = 'tooltip' ;
tooltip . className = 'tooltip' ;
const opts = {
const optsShort = {
timeZone : currentTimezone === 'TAI' ? 'UTC' : currentTimezone ,
timeZone : currentTimezone === 'TAI' ? 'UTC' : currentTimezone ,
year : 'numeric' , month : 'short' , day : 'numeric' ,
year : 'numeric' , month : 'short' , day : 'numeric' ,
hour : '2-digit' , minute : '2-digit' , second : '2-digit' ,
hour : '2-digit' , minute : '2-digit' ,
hour12 : false
hour12 : false
} ;
} ;
const startStr = formatCobieTimestamp ( ev . cobStart ) ;
const startStr = formatCobieTimestamp ( ev . cobStart ) ;
const endStr = formatCobieTimestamp ( ev . cobEnd ) ;
const endStr = formatCobieTimestamp ( ev . cobEnd ) ;
const startDate = fromCobiets ( ev . cobStart ) . toLocaleString ( 'en-US' , opts ) ;
const startDate = fromCobiets ( ev . cobStart ) . toLocaleString ( 'en-US' , optsShort ) ;
const endDate = fromCobiets ( ev . cobEnd ) . toLocaleString ( 'en-US' , opts ) ;
const endDate = fromCobiets ( ev . cobEnd ) . toLocaleString ( 'en-US' , optsShort ) ;
const seriesStart = formatCobieTimestamp ( ev . seriesStart ) ;
const seriesEnd = isFinite ( ev . seriesEnd ) ? formatCobieTimestamp ( ev . seriesEnd ) : '∞' ;
tooltip . innerHTML =
tooltip . innerHTML =
` <strong> ${ ev . label } </strong><br> ` +
` <strong> ${ ev . label } </strong><br> ` +
` Start: ${ startStr } <br> ` +
` Start: ${ startStr } ( ${ startDate } ) <br>` +
` End: ${ endStr } <br> ` +
( ev . cobEnd > ev . cobStart ? ` End: ${ endStr } ( ${ endDate } )<br> ` : '' ) +
` ${ startDate } – ${ endDate } ` ;
` Series: ${ seriesStart } – ${ seriesEnd } ` ;
elem . appendChild ( tooltip ) ;
elem . appendChild ( tooltip ) ;
timeline . appendChild ( elem ) ;
timeline . appendChild ( elem ) ;
} ) ;
} ) ;
@@ -1004,6 +1032,9 @@ document.getElementById('timezone').addEventListener('change', (e) => {
currentTimezone = e . target . value ;
currentTimezone = e . target . value ;
updateCurrentTime ( ) ;
updateCurrentTime ( ) ;
updateCalendar ( ) ;
updateCalendar ( ) ;
if ( currentDetailCob !== null ) {
showEonstripDetail ( currentDetailCob ) ;
}
} ) ;
} ) ;
// Set default timezone based on user's locale
// Set default timezone based on user's locale