git/aika/main

repository init, added sources, added license, added readme

diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..fa17d49
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,9 @@
+This is free and unencumbered software released into the public domain.
+
+Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.
+
+In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+For more information, please refer to <http://unlicense.org/>
diff --git a/README b/README
new file mode 100644
index 0000000..32434af
--- /dev/null
+++ b/README
@@ -0,0 +1,21 @@
+# AIKA
+
+## About
+
+Aika is a repository of mine dedicated to Arvelie and Neralie utilities, in an effort to make these time systems more accessible.
+
+I'm only comfortable with coding in C, and scripting in POSIX compliant shell, so that's likely all that will be offered here unless I learn other languages well enough to port to them.
+
+I'd consider myself below average at programming in a general sense, so it's likely that some problems will be ran into every so often with these implementations, if something unexpected occurs. If that does happen, please feel free to reach out to me via email at git@faen.sh.
+
+## Compiling
+
+To compile C source code, grab `gcc` from your package manager and run `gcc <source_file.c> -o <desired binary name>`
+
+## Conributions
+
+Contributions are welcome, of course! I would love for people to fork this work and expand on it, and make Arvelie and Neralie more accessible! That's my goal here.
+
+## License
+
+This software is licensed under the Unlicense. For more information, please visit https://unlicense.org/.
diff --git a/arvelie.c b/arvelie.c
new file mode 100644
index 0000000..c08a074
--- /dev/null
+++ b/arvelie.c
@@ -0,0 +1,28 @@
+#include <stdio.h>
+#include <time.h>
+
+void prArvelie() {
+ time_t t = time(NULL);
+ struct tm *tm = localtime(&t);
+ int doy = tm->tm_yday + 1;
+ int y = tm->tm_year % 100;
+ int yFull = tm->tm_year + 1900;
+ int ly = (yFull % 4 == 0 && yFull % 100 != 0) || (yFull % 400 == 0);
+ char mList[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+
+ if (doy == 365) {
+ printf("%02d+00\n", y);
+ } else if (doy == 366 && ly) {
+ printf("%02d+01\n", y);
+ } else {
+ if (ly && doy > 365) {
+ doy--;
+ }
+ printf("%02d%c%02d\n", y, mList[(doy - 1) / 14], (doy - 1) % 14 + 1);
+ }
+}
+
+int main() {
+ prArvelie();
+ return 0;
+}
diff --git a/arvelie.sh b/arvelie.sh
new file mode 100755
index 0000000..3e604c5
--- /dev/null
+++ b/arvelie.sh
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+doy=$(date +%j)
+y=$(date +%y)
+yFull=$(date +%Y)
+ly=$(( (yFull % 4 == 0 && yFull % 100 != 0) || yFull % 400 == 0 ))
+mList="A B C D E F G H I J K L M N O P Q R S T U V W X Y Z"
+
+set -- $mList
+
+if [ "$doy" -eq 365 ]; then
+ echo "$y+00"
+elif [ "$doy" -eq 366 ] && [ "$ly" -eq 1 ]; then
+ echo "$y+01"
+else
+ if [ "$ly" -eq 1 ] && [ "$doy" -gt 365 ]; then
+ doy=$((doy - 1))
+ fi
+ mIndex=$(( (doy - 1) / 14 ))
+ dom=$(( (doy - 1) % 14 + 1 ))
+ eval mLetter=\$"{$((mIndex + 1))}"
+ printf "%s%s%02d\n" "$y" "$mLetter" "$dom"
+fi
diff --git a/neralie.c b/neralie.c
new file mode 100644
index 0000000..c81bee4
--- /dev/null
+++ b/neralie.c
@@ -0,0 +1,23 @@
+#include <stdio.h>
+#include <time.h>
+
+void prNera() {
+ struct timespec ts;
+ struct tm *tm;
+ time_t t;
+
+ clock_gettime(CLOCK_REALTIME, &ts);
+ t = ts.tv_sec;
+ tm = localtime(&t);
+
+ long ms = tm->tm_hour * 3600000 + tm->tm_min * 60000 + tm->tm_sec * 1000 + ts.tv_nsec / 1000000;
+ int beat = ms / 86400;
+ int frac = ms % 86400;
+
+ printf("%03d:%03d\n", beat, frac * 1000 / 86400);
+}
+
+int main() {
+ prNera();
+ return 0;
+}
diff --git a/neralie.sh b/neralie.sh
new file mode 100755
index 0000000..7bb9967
--- /dev/null
+++ b/neralie.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+h=$(date +%k)
+m=$(date +%-M)
+s=$(date +%S)
+ms=$(( (h*3600 + m*60 + s) * 1000 ))
+nera=$((ms * 1000 / 86400))
+
+printf "%03d:%03d\n" $((nera / 1000)) $((nera % 1000))