You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
proxysql/deps/sqlite3/from_unixtime.patch

56 lines
1.6 KiB

--- sqlite3.c.O 2025-05-29 14:35:06.000000000 +0000
+++ sqlite3.c 2025-05-30 14:53:11.510407512 +0000
@@ -25954,6 +25954,44 @@
}
/*
+** from_unixtime( TIMESTRING)
+**
+** Return YYYY-MM-DD HH:MM:SS
+*/
+static void from_unixtimeFunc(
+ sqlite3_context *context,
+ int argc,
+ sqlite3_value **argv
+){
+ DateTime p;
+ int i, n;
+ const unsigned char *z;
+ int eType;
+ memset(&p, 0, sizeof(p));
+ if( argc==0 ){
+ setDateTimeToCurrent(context, &p);
+ return;
+ }
+ if( (eType = sqlite3_value_type(argv[0]))==SQLITE_FLOAT
+ || eType==SQLITE_INTEGER ){
+ setRawDateNumber(&p, sqlite3_value_double(argv[0]));
+ }else{
+ z = sqlite3_value_text(argv[0]);
+ if( !z || parseDateOrTime(context, (char*)z, &p) ){
+ return;
+ }
+ }
+ if( z==0 || parseModifier(context, (char*)"unixepoch", 9, &p, 0) ) return;
+ computeJD(&p);
+ if( p.isError || !validJulianDay(p.iJD) ) return;
+ char zBuf[100];
+ computeYMD_HMS(&p);
+ sqlite3_snprintf(sizeof(zBuf), zBuf, "%04d-%02d-%02d %02d:%02d:%02d",
+ p.Y, p.M, p.D, p.h, p.m, (int)(p.s));
+ sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT);
+}
+
+/*
** time( TIMESTRING, MOD, MOD, ...)
**
** Return HH:MM:SS
@@ -26520,6 +26558,7 @@
#ifdef SQLITE_DEBUG
PURE_DATE(datedebug, -1, 0, 0, datedebugFunc ),
#endif
+ DFUNCTION(from_unixtime, -1, 0, 0, from_unixtimeFunc ),
DFUNCTION(current_time, 0, 0, 0, ctimeFunc ),
DFUNCTION(current_timestamp, 0, 0, 0, ctimestampFunc),
DFUNCTION(current_date, 0, 0, 0, cdateFunc ),