From 62abdf3f93dc6edbcfac202d89ed9bb5f61cbb1c Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Sun, 19 Nov 2023 20:24:56 -0600 Subject: [PATCH] added: `Date.start_of_month()` and `Date.end_of_month()` --- build.sh | 3 ++- core/time/date.onyx | 16 ++++++++++++++++ misc/vscode/package.json | 6 +++--- settings.sh | 3 +++ 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/build.sh b/build.sh index 9cf73655..d6ea7e01 100755 --- a/build.sh +++ b/build.sh @@ -1,7 +1,6 @@ #!/bin/sh DIST_DIR="./dist" -ONYX_INSTALL_DIR="$HOME/.onyx" compile_all() { if [ "$ONYX_RUNTIME_LIBRARY" = "ovmwasm" ]; then @@ -73,6 +72,8 @@ compress_all() { } install_all() { + [ -z ${ONYX_INSTALL_DIR+x} ] && echo "Please set ONYX_INSTALL_DIR to install Onyx." && exit 1 + package_all echo "Installing to $ONYX_INSTALL_DIR" diff --git a/core/time/date.onyx b/core/time/date.onyx index aea4ba85..48ea2e00 100644 --- a/core/time/date.onyx +++ b/core/time/date.onyx @@ -88,6 +88,22 @@ Date :: struct { return dig % 7; } + start_of_month :: (d: Date) -> Date { + return .{ + year = d.year, + month = d.month, + day = 1, + }; + } + + end_of_month :: (d: Date) -> Date { + return .{ + year = d.year, + month = d.month, + day = Date.month_durations[d.month], + }; + } + is_before :: (d1, d2: Date) -> bool { if d1.year != d2.year do return d1.year < d2.year; if d1.month != d2.month do return d1.month < d2.month; diff --git a/misc/vscode/package.json b/misc/vscode/package.json index 2cc129f1..a7511f14 100644 --- a/misc/vscode/package.json +++ b/misc/vscode/package.json @@ -1,9 +1,9 @@ { - "name": "onyx", - "displayName": "Onyx", + "name": "onyxlang", + "displayName": "Onyx Programming Language", "description": "Onyx syntax highlighting and debugger support.", "version": "0.1.8", - "publisher": "brendanfh", + "publisher": "onyxlang", "license": "BSD-2-Clause", "engines": { "vscode": "^1.75.0" diff --git a/settings.sh b/settings.sh index f6c48ca2..d203f020 100644 --- a/settings.sh +++ b/settings.sh @@ -1,4 +1,7 @@ +# Where Onyx will be installed from the "./build.sh install" command. +export ONYX_INSTALL_DIR="$HOME/.onyx" + # The compiler to use. Only GCC and TCC have been tested. export ONYX_CC='gcc' -- 2.25.1