- It is the th day of the week
+
+ It is the {{ unitydate.weekday + 1 }}{{ nth(unitydate.weekday + 1) }} day of the week, placeholder extra long day!
\ No newline at end of file
diff --git a/nuxt.config.ts b/nuxt.config.ts
index 33e8ebd..3a13ea1 100644
--- a/nuxt.config.ts
+++ b/nuxt.config.ts
@@ -1,5 +1,12 @@
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
devtools: { enabled: true },
- pages: true
+ pages: true,
+ // app: {
+ // head: {
+ // script: [
+ // "/assets/unitymath.js"
+ // ],
+ // }
+ // }
})
diff --git a/assets/unitymath.js b/utils/unitymath.js
similarity index 60%
rename from assets/unitymath.js
rename to utils/unitymath.js
index 1ff8b5b..e87e7a6 100644
--- a/assets/unitymath.js
+++ b/utils/unitymath.js
@@ -6,7 +6,7 @@ const minutems = secondms * secondsperminute
const hourms = minutems * minutesperhour
const dayms = hourms * hoursperday
-const solaryear = 365.242
+const solaryear = 365.2425
const yeardays = 366
const leapchange = -6
@@ -16,90 +16,85 @@ const monthdays = 30
const leapfreq = 8
-const exleapcyclelength = 800;
+const exleapfreq = 800;
const exleapyear = 500;
const exleapyearlowbound = Math.floor(exleapyear / leapfreq) * leapfreq;
const exleapyearupbound = exleapyearlowbound + leapfreq;
const exleapyearlowbounddays = (exleapyearlowbound * yeardays) + ((exleapyearlowbound / leapfreq) * leapchange);
const exleapyearupbounddays = (exleapyearupbound * yeardays) + leapchange + ((exleapyearupbound / leapfreq) * leapchange);
-const exleapcycledays = (exleapcyclelength * yeardays) + leapchange + ((exleapcyclelength / leapfreq) * leapchange)
+const exleapcycledays = (exleapfreq * yeardays) + leapchange + ((exleapfreq / leapfreq) * leapchange)
const leapcycledays = (leapfreq * yeardays) + leapchange;
const unityzero = Date.parse("2000-03-08T00:00:00.000Z");
-function unixtounity(unixtime) {
+export function unixtounity(unixtime) {
const unitytime = unixtime - unityzero;
const days = unitytime / dayms;
const exleapcycles = Math.floor(days / exleapcycledays);
-
const exleapcycleprogress = days - exleapcycles * exleapcycledays;
let leapcycles;
-
let leapcycleprogress;
-
let leapcyclehasex;
-
if (exleapcycleprogress < exleapyearupbounddays) {
-
leapcycles = Math.floor(exleapcycleprogress / leapcycledays);
-
leapcycleprogress = exleapcycleprogress - leapcycles * leapcycledays;
-
leapcyclehasex = exleapcycleprogress >= exleapyearlowbounddays;
-
} else {
-
leapcycles = Math.floor((exleapcycleprogress - leapchange)/ leapcycledays);
-
leapcycleprogress = (exleapcycleprogress - (leapcycles * leapcycledays)) - leapchange;
-
leapcyclehasex = false;
-
}
let leapyearspassed;
-
if (leapcycleprogress < leapyeardays) {
-
leapyearspassed = 0;
-
} else if (!leapcyclehasex || leapcycleprogress < (2 * leapyeardays) + (3 * yeardays)) {
-
leapyearspassed = 1;
-
} else {
-
leapyearspassed = 2;
-
}
const years = Math.floor((leapcycleprogress - (leapchange * leapyearspassed)) / yeardays);
-
const yearprogress = leapcycleprogress - ((years * yeardays) + (leapchange * leapyearspassed));
const months = Math.floor(yearprogress / monthdays);
-
const monthprogress = yearprogress - months * monthdays;
- const date = Math.floor(monthprogress);
+ const day = Math.floor(monthprogress);
- return `${12000 + (exleapcycles * exleapcyclelength) + (leapcycles * leapfreq) + years}-${months + 1}-${date + 1}`
+ const weekday = day % 6;
+
+ const date = {
+ year: 12000 + (exleapcycles * exleapfreq) + (leapcycles * leapfreq) + years,
+ month: months,
+ day: day,
+ weekday: weekday,
+ };
+
+ return date
}
-const oldtimes = new Date();
-oldtimes.setYear(-600)
-
-console.log(unixtounity(Date.now()))
-console.log(unixtounity(oldtimes.getTime()))
-console.log(unixtounity(Date.parse("2000-01-01")))
-console.log(unixtounity(Date.parse("2000-03-07")))
-console.log(unixtounity(Date.parse("2000-03-08")))
-console.log(unixtounity(Date.parse("2000-03-09")))
-console.log(unixtounity(Date.parse("2001-03-07")))
-console.log(unixtounity(Date.parse("3000-03-07")))
-console.log(unixtounity(Date.parse("42400-03-07")))
\ No newline at end of file
+// console.log(unixtounity(Date.parse("1990-06-06")))
+// console.log(unixtounity(Date.parse("1890-06-06")))
+// console.log(unixtounity(Date.parse("1990-06-06")))
+// console.log(unixtounity(Date.parse("1993-06-06")))
+// console.log(unixtounity(Date.parse("1998-06-06")))
+// console.log(unixtounity(Date.parse("1999-06-06")))
+// console.log(unixtounity(Date.parse("1999-12-31")))
+// console.log(unixtounity(Date.parse("2000-03-01")))
+// console.log(unixtounity(Date.parse("2000-03-02")))
+// console.log(unixtounity(Date.parse("2000-03-07")))
+// console.log(unixtounity(Date.parse("2000-03-08")))
+// console.log(unixtounity(Date.parse("2000-03-09")))
+// console.log(unixtounity(Date.parse("2000-04-07")))
+// console.log(unixtounity(Date.parse("2000-06-06")))
+// console.log(unixtounity(Date.parse("2001-06-06")))
+// console.log(unixtounity(Date.parse("2002-06-06")))
+// console.log(unixtounity(Date.parse("2006-06-06")))
+// console.log(unixtounity(Date.parse("2010-06-06")))
+// console.log(unixtounity(new Date()))
\ No newline at end of file