diff --git a/src/Formats/Types.luau b/src/Formats/Types.luau index 9060244..63e3d79 100644 --- a/src/Formats/Types.luau +++ b/src/Formats/Types.luau @@ -821,6 +821,7 @@ local function civilFromDays(z: number): (number, number, number) local m = if mp < 10 then mp + 3 else mp - 9 return (if m <= 2 then y + 1 else y), m, d end +DateLib.civilFromDays = civilFromDays -- days since 1970-01-01 -> year, month, day (proleptic Gregorian) local MDAYS = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } -- new(fields) -> Date (kind inferred from the fields present when not given) function DateLib.new(f: { [string]: any }): Date diff --git a/src/Formats/codecs/model/MeshFlatten.luau b/src/Formats/codecs/model/MeshFlatten.luau index 3c26fc6..cf3fb69 100644 --- a/src/Formats/codecs/model/MeshFlatten.luau +++ b/src/Formats/codecs/model/MeshFlatten.luau @@ -109,20 +109,7 @@ end -- ------------------------------------------------------------------------------------------------ transforms local IDENTITY = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 } --- column-major 4x4 product a * b -local function mul(a: { number }, b: { number }): { number } - local m = table.create(16, 0) - for c = 0, 3 do - for r = 0, 3 do - local s = 0 - for k = 0, 3 do - s += a[k * 4 + r + 1] * b[c * 4 + k + 1] - end - m[c * 4 + r + 1] = s - end - end - return m -end +local mul = Types.Scene.mul -- column-major 4x4 product a * b local function numList(v: any, n: number): boolean if type(v) ~= "table" then diff --git a/src/Formats/containers/Zip/init.luau b/src/Formats/containers/Zip/init.luau index 0fcf385..9133f94 100644 --- a/src/Formats/containers/Zip/init.luau +++ b/src/Formats/containers/Zip/init.luau @@ -19,6 +19,7 @@ -- Never throws: corrupt archives and bad arguments return nil, Err. Parsing runs interpreted (it is cold); the native -- code it reaches (Deflate, Crc32) does not throw either. local Err = require("@formats/core/Err") +local Types = require("@formats/Types") local Bytes = require("@formats/core/Bytes") local Crc32 = require("@formats/core/Crc32") local Deflate = require("@formats/codecs/compress/Deflate") @@ -421,18 +422,7 @@ function Zip.writer(): any end -- days from 1970-01-01 to y-m-d (proleptic Gregorian) -local function civil(z: number): (number, number, number) - z += 719468 - local era = (if z >= 0 then z else z - 146096) // 146097 - local doe = z - era * 146097 - local yoe = (doe - doe // 1460 + doe // 36524 - doe // 146096) // 365 - local y = yoe + era * 400 - local doy = doe - (365 * yoe + yoe // 4 - yoe // 100) - local mp = (5 * doy + 2) // 153 - local d = doy - (153 * mp + 2) // 5 + 1 - local m = if mp < 10 then mp + 3 else mp - 9 - return (if m <= 2 then y + 1 else y), m, d -end +local civil = Types.Date.civilFromDays local function daysFrom(y: number, m: number, d: number): number y = if m <= 2 then y - 1 else y local era = (if y >= 0 then y else y - 399) // 400 diff --git a/src/Formats/vector/svg/Style.luau b/src/Formats/vector/svg/Style.luau index 10ff39e..da4fd36 100644 --- a/src/Formats/vector/svg/Style.luau +++ b/src/Formats/vector/svg/Style.luau @@ -4,6 +4,7 @@ -- lengths with units, transform lists, style="" declarations, and a CSS subset for