Merge branch 'fix/dartdoc'

This commit is contained in:
zontreck 2025-05-24 23:35:45 -07:00
commit 7df013a6aa
4 changed files with 59 additions and 16 deletions

8
Jenkinsfile vendored
View file

@ -24,10 +24,10 @@ pipeline {
unset WORKSPACE_TMP unset WORKSPACE_TMP
rm -rf doc rm -rf doc
dart pub get dart pub get
# dart doc dart doc
# Workaround for dart doc being broken at the moment #(EDIT: Workaround is not currently required.) Workaround for dart doc being broken at the moment
dart pub global activate dartdoc #dart pub global activate dartdoc
dart pub global run dartdoc #dart pub global run dartdoc
tar -cvf docs.tgz doc/api/* tar -cvf docs.tgz doc/api/*

View file

@ -1,5 +1,5 @@
class Constants { class Constants {
static const VERSION = "1.4.020325+1215"; static const VERSION = "1.4.052425+2332";
static const NBT_REVISION = "1.4.020325+1215"; static const NBT_REVISION = "1.4.020325+1215";
static const ARGS_REVISION = "1.4.012225+0413"; static const ARGS_REVISION = "1.4.012225+0413";
} }

View file

@ -1,14 +1,35 @@
import '../nbt/Stream.dart'; /// [Time] is used as a way to serialize and deserialize time based notations.
///
/// When interacting with this, you can even parse Durations
class Time { class Time {
int days;
int hours; int hours;
int minutes; int minutes;
int seconds; int seconds;
Time({required this.hours, required this.minutes, required this.seconds}) { Time(
{required this.days,
required this.hours,
required this.minutes,
required this.seconds}) {
autofix(); autofix();
} }
static Time fromDuration(Duration duration) {
int days = duration.inDays;
int hours = duration.inHours.remainder(24);
int minutes = duration.inMinutes.remainder(60);
int seconds = duration.inSeconds.remainder(60);
return Time(days: days, hours: hours, minutes: minutes, seconds: seconds);
}
Duration toDuration() {
return Duration(
days: days, hours: hours, minutes: minutes, seconds: seconds);
}
int getTotalSeconds() { int getTotalSeconds() {
int current = 0; int current = 0;
current += seconds; current += seconds;
@ -59,9 +80,13 @@ class Time {
int totalSeconds = getTotalSeconds(); int totalSeconds = getTotalSeconds();
if (totalSeconds < 0) totalSeconds = 0; if (totalSeconds < 0) totalSeconds = 0;
int one_day = (1 * 60 * 60 * 24);
int one_hour = (1 * 60 * 60); int one_hour = (1 * 60 * 60);
int one_minute = (1 * 60); int one_minute = (1 * 60);
int days = (totalSeconds / 60 / 60 / 24).round();
totalSeconds -= (days * one_day);
int hours = (totalSeconds / 60 / 60).round(); int hours = (totalSeconds / 60 / 60).round();
totalSeconds -= (hours * one_hour); totalSeconds -= (hours * one_hour);
@ -70,27 +95,43 @@ class Time {
int seconds = totalSeconds; int seconds = totalSeconds;
this.days = days;
this.hours = hours; this.hours = hours;
this.minutes = minutes; this.minutes = minutes;
this.seconds = seconds; this.seconds = seconds;
} }
Time copy() { Time copy() {
return Time(hours: hours, minutes: minutes, seconds: seconds); return Time(days: days, hours: hours, minutes: minutes, seconds: seconds);
} }
factory Time.copy(Time other) { factory Time.copy(Time other) {
return Time( return Time(
hours: other.hours, minutes: other.minutes, seconds: other.seconds); days: other.days,
hours: other.hours,
minutes: other.minutes,
seconds: other.seconds);
} }
factory Time.fromNotation(String notation) { factory Time.fromNotation(String notation) {
int days = 0;
int hours = 0; int hours = 0;
int minutes = 0; int minutes = 0;
int seconds = 0; int seconds = 0;
List<String> current = []; List<String> current = [];
String val = notation; String val = notation;
if (val.indexOf('d') == -1) {
days = 0;
} else {
current = val.split('d');
days = int.parse(current[0]);
if (current.length == 2) {
val = current[1];
} else
val = "";
}
if (val.indexOf('h') == -1) { if (val.indexOf('h') == -1) {
hours = 0; hours = 0;
} else { } else {
@ -131,17 +172,19 @@ class Time {
seconds += int.parse(val); seconds += int.parse(val);
} }
return Time(hours: hours, minutes: minutes, seconds: seconds); return Time(days: days, hours: hours, minutes: minutes, seconds: seconds);
} }
@override @override
String toString() { String toString() {
StringBuilder builder = StringBuilder(); List<String> parts = [];
if (hours > 0) builder.append("${hours}h");
if (minutes > 0) builder.append("${minutes}m");
if (seconds > 0) builder.append("${seconds}s");
return "${builder}"; if (days > 0) parts.add('${days}d');
if (hours > 0) parts.add('${hours}h');
if (minutes > 0) parts.add('${minutes}m');
if (seconds > 0) parts.add('${seconds}s');
return parts.join(' ');
} }
} }

View file

@ -1,6 +1,6 @@
name: libac_dart name: libac_dart
description: "Aria's Creations code library" description: "Aria's Creations code library"
version: 1.4.020325+1215 version: 1.4.052425+2332
homepage: "https://zontreck.com" homepage: "https://zontreck.com"
environment: environment: