From e4917f8cea6e0094457016e99f036ab33226644b Mon Sep 17 00:00:00 2001 From: Effie Date: Tue, 11 Jun 2024 17:40:06 +1000 Subject: [PATCH] starts the math for the gregorian to unity conversion --- assets/main.css | 5 -- assets/unitymath.js | 74 +++++++++++++++++++ components/main/calblock.vue | 9 +++ components/main/calendar/frame.vue | 12 +-- components/main/calendar/{ => frame}/days.vue | 2 +- .../main/calendar/{ => frame}/month.vue | 2 +- .../main/calendar/{ => frame}/singleday.vue | 0 components/main/calendar/today.vue | 13 +++- components/main/calendar/today/holiday.vue | 7 ++ components/main/calendar/today/is.vue | 36 +++++++++ components/main/calendar/today/weekday.vue | 7 ++ components/main/titleblock.vue | 22 +++++- components/navfoot.vue | 2 +- layouts/default.vue | 1 + pages/index.vue | 8 +- 15 files changed, 179 insertions(+), 21 deletions(-) create mode 100644 assets/unitymath.js rename components/main/calendar/{ => frame}/days.vue (93%) rename components/main/calendar/{ => frame}/month.vue (92%) rename components/main/calendar/{ => frame}/singleday.vue (100%) create mode 100644 components/main/calendar/today/holiday.vue create mode 100644 components/main/calendar/today/is.vue create mode 100644 components/main/calendar/today/weekday.vue diff --git a/assets/main.css b/assets/main.css index 9b128ec..0f618b7 100644 --- a/assets/main.css +++ b/assets/main.css @@ -2,9 +2,4 @@ body { background-color: yellow; margin: 0; height: 100vh; -} - -h1 { - margin: auto; - width: max-content; } \ No newline at end of file diff --git a/assets/unitymath.js b/assets/unitymath.js new file mode 100644 index 0000000..72233fc --- /dev/null +++ b/assets/unitymath.js @@ -0,0 +1,74 @@ +const hoursperday = 24 +const minutesperhour = 60 +const secondsperminute = 60 +const secondms = 1000 +const minutems = secondms * secondsperminute +const hourms = minutems * minutesperhour +const dayms = hourms * hoursperday + +const solaryear = 365.242 + +const yeardays = 366 +const leapchange = -6 +const leapyeardays = yeardays + leapchange + +const monthdays = 30 + +const leapfreq = 8 + +const exleapcyclelength = 800; +const extraleapyear = 500; + +const exleapcycledays = (exleapcyclelength * yeardays) + leapchange + ((exleapcyclelength / leapfreq) * leapchange) + +const leapcycledays = (leapfreq * yeardays) + leapchange; + +const unityzero = Date.parse("2000-03-08T00:00:00.000Z"); + +function unixtounity(unixtime) { + const unitytime = unixtime - unityzero; + const days = unitytime / dayms; + + const exleapcycles = Math.floor(days / exleapcycledays); + + const exleapcycleprogress = days - exleapcycles * exleapcycledays; + + const leapcycles = Math.floor(exleapcycleprogress / leapcycledays); + + const leapcycleprogress = exleapcycleprogress - leapcycles * leapcycledays; + + let years; + + let yearprogress; + + if (leapcycleprogress > leapyeardays) { + + years = Math.floor((leapcycleprogress - leapyeardays) / yeardays) + 1; + + yearprogress = leapcycleprogress - ((years * yeardays) + leapchange); + + } else { + + years = 0; + + yearprogress = leapcycleprogress; + + } + + const months = Math.floor(yearprogress / monthdays); + + const monthprogress = yearprogress - months * monthdays; + + const date = Math.floor(monthprogress); + + return `${12000 + (exleapcycles * exleapcyclelength) + (leapcycles * leapfreq) + years}-${months + 1}-${date + 1}` + +} + +const oldtimes = new Date(); +oldtimes.setYear(-600) + +console.log(unixtounity(Date.now())) +console.log(unixtounity(Date.parse("3500-03-03"))) +console.log(unixtounity(Date.parse("0010-12-30"))) +console.log(unixtounity(oldtimes.getTime())) \ No newline at end of file diff --git a/components/main/calblock.vue b/components/main/calblock.vue index 92275b4..4369200 100644 --- a/components/main/calblock.vue +++ b/components/main/calblock.vue @@ -5,11 +5,20 @@ } + .calendarpart { + width: 50%; + border: 1px solid black; + } + @media (max-width: 720px) { .indexcalendar { flex-direction: column; } + .calendarpart { + width: 100%; + } + } diff --git a/components/main/calendar/frame.vue b/components/main/calendar/frame.vue index ded28c9..5bd5941 100644 --- a/components/main/calendar/frame.vue +++ b/components/main/calendar/frame.vue @@ -19,17 +19,13 @@ \ No newline at end of file diff --git a/components/main/calendar/today/holiday.vue b/components/main/calendar/today/holiday.vue new file mode 100644 index 0000000..d382b3c --- /dev/null +++ b/components/main/calendar/today/holiday.vue @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/components/main/calendar/today/is.vue b/components/main/calendar/today/is.vue new file mode 100644 index 0000000..1048893 --- /dev/null +++ b/components/main/calendar/today/is.vue @@ -0,0 +1,36 @@ + + + + + + + + \ No newline at end of file diff --git a/components/main/calendar/today/weekday.vue b/components/main/calendar/today/weekday.vue new file mode 100644 index 0000000..91be274 --- /dev/null +++ b/components/main/calendar/today/weekday.vue @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/components/main/titleblock.vue b/components/main/titleblock.vue index b861cb4..946c7b7 100644 --- a/components/main/titleblock.vue +++ b/components/main/titleblock.vue @@ -1,6 +1,24 @@ + + + + + + \ No newline at end of file diff --git a/components/navfoot.vue b/components/navfoot.vue index 47455f4..b8318d5 100644 --- a/components/navfoot.vue +++ b/components/navfoot.vue @@ -10,7 +10,7 @@ .navlist { - display: flex; gap: 6rem; justify-content: center; + display: flex; gap: 1.2rem; justify-content: center; } diff --git a/layouts/default.vue b/layouts/default.vue index 0152049..774f6be 100644 --- a/layouts/default.vue +++ b/layouts/default.vue @@ -5,6 +5,7 @@ display: flex; flex-direction: column; align-items: center; justify-content: space-between; + overflow: auto; } diff --git a/pages/index.vue b/pages/index.vue index 8e332ea..13cb8cd 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -3,7 +3,8 @@ .mainblock { max-width: 72rem; width: 100%; - display: flex; flex-direction: column; gap: 7.2rem; + display: flex; flex-direction: column; gap: 6rem; + padding-top: 2.4rem; } @@ -11,7 +12,10 @@