feat: readd date internals

This commit is contained in:
TopchetoEU 2023-10-06 12:03:33 +03:00
parent a17ec737b7
commit fc705e7383
Signed by: topchetoeu
GPG Key ID: 6531B8583E5F6ED4
2 changed files with 9 additions and 3 deletions

View File

@ -254,6 +254,12 @@ public class DateLib {
else return normal.getTimeInMillis();
}
@Native
public String toString() {
return normal.getTime().toString();
}
@Native
public DateLib(long timestamp) {
normal = Calendar.getInstance();
utc = Calendar.getInstance();

View File

@ -15,9 +15,6 @@ public class Internals {
private static final DataKey<HashMap<Integer, Thread>> THREADS = new DataKey<>();
private static final DataKey<Integer> I = new DataKey<>();
@Native public static FunctionValue bind(FunctionValue func, Object thisArg) throws InterruptedException {
return FunctionLib.bind(func, thisArg);
}
@Native public static void log(Context ctx, Object ...args) throws InterruptedException {
for (var arg : args) {
Values.printValue(ctx, arg);
@ -87,6 +84,9 @@ public class Internals {
var wp = env.wrappersProvider;
var glob = env.global = new GlobalScope(NativeWrapperProvider.makeNamespace(env, Internals.class));
glob.define(null, "Math", false, NativeWrapperProvider.makeNamespace(env, MathLib.class));
glob.define(null, "Date", false, wp.getConstr(DateLib.class));
glob.define(null, "Object", false, wp.getConstr(ObjectLib.class));
glob.define(null, "Function", false, wp.getConstr(FunctionLib.class));
glob.define(null, "Array", false, wp.getConstr(ArrayLib.class));