Added CGI stuff and unixtime function.

This commit is contained in:
brad Arant committed 2025-11-07 10:22:20 -08:00
1 parent 280d4b8aa2
commit 078a73664c
72 files changed
+10881 -297

No files matched your search

+43 -3
View File
@@ -3,6 +3,7 @@
#include <format>
#include <iostream>
#include <time.h>
#include <chrono>
namespace jet {
@@ -11,7 +12,7 @@ namespace jet {
doubleValue = 0;
in.skipWhitespace();
if(in.startsWith("$[") || in.startsWith("#[")) {
string = tag.getVariable(in);
doubleValue = string.asDouble();
@@ -36,7 +37,7 @@ namespace jet {
if(in.ifNext(")")) {
string = parm1.string.substring(parm2.string.asInteger());
} else if(!in.ifNext(","))
throw coreutils::Exception("Expecting , in SUBSTRING expression.");
throw coreutils::Exception("Expecting , in SUBSTRING expression.");
Operand parm3(in, tag);
if(in.ifNext(")")) {
string = parm1.string.substring(parm2.string.asInteger(), parm3.string.asInteger());
@@ -122,6 +123,45 @@ namespace jet {
isNumber = true;
string = std::format("{:.12f}", doubleValue);
string.removeTrailingZeros();
} else if(in.ifNextIgnoreCase("ABS")) {
} else if(in.ifNextIgnoreCase("MAX")) {
} else if(in.ifNextIgnoreCase("MIN")) {
} else if(in.ifNextIgnoreCase("POW")) {
} else if(in.ifNextIgnoreCase("SIN")) {
} else if(in.ifNextIgnoreCase("ASIN")) {
} else if(in.ifNextIgnoreCase("COS")) {
} else if(in.ifNextIgnoreCase("ACOS")) {
} else if(in.ifNextIgnoreCase("ATAN")) {
} else if(in.ifNextIgnoreCase("SQRT")) {
} else if(in.ifNextIgnoreCase("TAN")) {
} else if(in.ifNextIgnoreCase("TRUNC")) {
} else if(in.ifNextIgnoreCase("CEIL")) {
} else if(in.ifNextIgnoreCase("FLOOR")) {
} else if(in.ifNextIgnoreCase("UNIXTIME")) {
if(!in.ifNext("("))
throw coreutils::Exception("Expecting ( for UNIXTIME.");
if(in.ifNext(")")) {
auto now = std::chrono::system_clock::now();
auto duration_since_epoch = now.time_since_epoch();
auto seconds_since_epoch = std::chrono::duration_cast<std::chrono::seconds>(duration_since_epoch);
int unixtime = seconds_since_epoch.count();
string << unixtime;
} else
throw coreutils::Exception("Expecting ) at end of UNIXTIME.");
} else if(in.ifNextIgnoreCase("true")) {
boolean = true;
string = "true";
@@ -138,7 +178,7 @@ namespace jet {
isNumber = false;
} else
throw coreutils::Exception("operand is not valid.");
in.skipWhitespace();
if(in.ifNext("!=") || in.ifNext("<>")) {