Time.java
/**
* Copyright 2010,2021 Nikolas S Boyd.
Permission is granted to copy this work provided this copyright statement is retained in all copies.
*/
package Hoot.Magnitudes;
import Hoot.Runtime.Functions.*;
import Hoot.Runtime.Faces.*;
import Hoot.Runtime.Values.*;
import Hoot.Runtime.Blocks.*;
import Smalltalk.Core.*;
import Smalltalk.Blocks.*;
import Smalltalk.Magnitudes.*;
import Hoot.Behaviors.*;
import Hoot.Behaviors.Nil;
import Hoot.Behaviors.Object;
import Hoot.Behaviors.True;
import Hoot.Behaviors.False;
import Hoot.Behaviors.Boolean;
import Hoot.Collections.*;
import Hoot.Collections.String;
import java.lang.System;
import java.time.Duration;
import java.time.LocalDateTime;
import Hoot.Runtime.Names.Primitive;
import Smalltalk.Magnitudes.Scalar;
public class Time extends Magnitude
{
public static Metaclass type() { return (Metaclass)Metaclass.$class; }
@Override public Metaclass $class() { return (Metaclass)Metaclass.$class; }
public static class Metaclass extends Magnitude.Metaclass
{
static final Time.Metaclass $class = new Time.Metaclass();
public Metaclass() {
this(Time.Metaclass.class);
}
public Metaclass(java.lang.Class aClass) {
super(aClass);
}
@Override public java.lang.Class outerClass() { return Time.class; }
/**
* @return
*/
@Override public Time $new()
{
java.lang.String exitID = "TimeMetatype>>$new";
Frame f0 = new Frame(exitID);
return f0.evaluate(() -> {
return (Time)f0.exit(exitID, new Time());
});
}
}
protected LocalDateTime localTime = Time.now();
/**
* @return
*/
public static Duration clockPrecision()
{
java.lang.String exitID = "Time>>$clockPrecision";
Frame f0 = new Frame(exitID);
long now = System.currentTimeMillis();
return (Duration)Duration.ofMillis((System.currentTimeMillis() - now));
}
/**
* @return
*/
public static LocalDateTime now()
{
java.lang.String exitID = "Time>>$now";
Frame f0 = new Frame(exitID);
return (LocalDateTime)LocalDateTime.now();
}
/**
* @return
*/
public LocalDateTime localTime()
{
java.lang.String exitID = "Time>>localTime";
Frame f0 = new Frame(exitID);
return (LocalDateTime)localTime;
}
/**
* @return
*/
public Boolean equals(final Time aTime)
{
java.lang.String exitID = "Time>>equals";
Frame f0 = new Frame(exitID);
return (Boolean)Boolean.from((localTime.equals(aTime.localTime())));
}
/**
* @return
*/
public Boolean lessThan(final Time aTime)
{
java.lang.String exitID = "Time>>lessThan";
Frame f0 = new Frame(exitID);
return (Boolean)Boolean.from(localTime.isBefore(aTime.localTime()));
}
/**
* @return
*/
public Boolean moreThan(final Time aTime)
{
java.lang.String exitID = "Time>>moreThan";
Frame f0 = new Frame(exitID);
return (Boolean)Boolean.from(localTime.isAfter(aTime.localTime()));
}
/**
* @return
*/
@Override public Boolean equals(final Magnitude value)
{
java.lang.String exitID = "Time>>equals";
Frame f0 = new Frame(exitID);
return (Boolean)Time.type().accepts(value).and(Predicate.with(f2 -> {
return (this.equals(((Time)value)));
}, ""));
}
/**
* @return
*/
@Override public Boolean lessThan(final Scalar value)
{
java.lang.String exitID = "Time>>lessThan";
Frame f0 = new Frame(exitID);
return (Boolean)Time.type().accepts(value).and(Predicate.with(f2 -> {
return (this.lessThan(((Time)value)));
}, ""));
}
/**
* @return
*/
@Override public Boolean moreThan(final Scalar value)
{
java.lang.String exitID = "Time>>moreThan";
Frame f0 = new Frame(exitID);
return (Boolean)Time.type().accepts(value).and(Predicate.with(f2 -> {
return (this.moreThan(((Time)value)));
}, ""));
}
/**
* @return
*/
public static String printTimeNow()
{
java.lang.String exitID = "Time>>$printTimeNow";
Frame f0 = new Frame(exitID);
return (String)Time.printTime(Time.now());
}
/**
* @return
*/
public static String printTime(final LocalDateTime time)
{
java.lang.String exitID = "Time>>$printTime";
Frame f0 = new Frame(exitID);
return (String)String.from(Primitive.printTime(time));
}
/**
* @return
*/
public static String formatTime_as(final LocalDateTime time, final String timeFormat)
{
java.lang.String exitID = "Time>>$formatTime_as";
Frame f0 = new Frame(exitID);
return (String)String.from(Primitive.formatTime(time, timeFormat.asPrimitive()));
}
}