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
rm -rf doc
dart pub get
# dart doc
# Workaround for dart doc being broken at the moment
dart pub global activate dartdoc
dart pub global run dartdoc
dart doc
#(EDIT: Workaround is not currently required.) Workaround for dart doc being broken at the moment
#dart pub global activate dartdoc
#dart pub global run dartdoc
tar -cvf docs.tgz doc/api/*

View file

@ -1,5 +1,5 @@
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 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 {
int days;
int hours;
int minutes;
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();
}
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 current = 0;
current += seconds;
@ -59,9 +80,13 @@ class Time {
int totalSeconds = getTotalSeconds();
if (totalSeconds < 0) totalSeconds = 0;
int one_day = (1 * 60 * 60 * 24);
int one_hour = (1 * 60 * 60);
int one_minute = (1 * 60);
int days = (totalSeconds / 60 / 60 / 24).round();
totalSeconds -= (days * one_day);
int hours = (totalSeconds / 60 / 60).round();
totalSeconds -= (hours * one_hour);
@ -70,27 +95,43 @@ class Time {
int seconds = totalSeconds;
this.days = days;
this.hours = hours;
this.minutes = minutes;
this.seconds = seconds;
}
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) {
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) {
int days = 0;
int hours = 0;
int minutes = 0;
int seconds = 0;
List<String> current = [];
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) {
hours = 0;
} else {
@ -131,17 +172,19 @@ class Time {
seconds += int.parse(val);
}
return Time(hours: hours, minutes: minutes, seconds: seconds);
return Time(days: days, hours: hours, minutes: minutes, seconds: seconds);
}
@override
String toString() {
StringBuilder builder = StringBuilder();
if (hours > 0) builder.append("${hours}h");
if (minutes > 0) builder.append("${minutes}m");
if (seconds > 0) builder.append("${seconds}s");
List<String> parts = [];
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
description: "Aria's Creations code library"
version: 1.4.020325+1215
version: 1.4.052425+2332
homepage: "https://zontreck.com"
environment: