@dolthub/doltlite-wasm 0.11.54 → 0.11.56
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/sqlite3-bundler-friendly.mjs +1 -305
- package/sqlite3-node.mjs +1 -305
- package/sqlite3.mjs +1 -305
- package/sqlite3.wasm +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dolthub/doltlite-wasm",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.56",
|
|
4
4
|
"description": "DoltLite compiled to WebAssembly: SQLite with Dolt-style version control (branches, commits, merge, diff) for the browser and any JS runtime.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.mjs",
|
|
@@ -5365,308 +5365,6 @@ async function createWasm() {
|
|
|
5365
5365
|
return 0;
|
|
5366
5366
|
};
|
|
5367
5367
|
|
|
5368
|
-
|
|
5369
|
-
var arraySum = (array, index) => {
|
|
5370
|
-
var sum = 0;
|
|
5371
|
-
for (var i = 0; i <= index; sum += array[i++]) {
|
|
5372
|
-
// no-op
|
|
5373
|
-
}
|
|
5374
|
-
return sum;
|
|
5375
|
-
};
|
|
5376
|
-
|
|
5377
|
-
|
|
5378
|
-
var MONTH_DAYS_LEAP = [31,29,31,30,31,30,31,31,30,31,30,31];
|
|
5379
|
-
|
|
5380
|
-
var MONTH_DAYS_REGULAR = [31,28,31,30,31,30,31,31,30,31,30,31];
|
|
5381
|
-
var addDays = (date, days) => {
|
|
5382
|
-
var newDate = new Date(date.getTime());
|
|
5383
|
-
while (days > 0) {
|
|
5384
|
-
var leap = isLeapYear(newDate.getFullYear());
|
|
5385
|
-
var currentMonth = newDate.getMonth();
|
|
5386
|
-
var daysInCurrentMonth = (leap ? MONTH_DAYS_LEAP : MONTH_DAYS_REGULAR)[currentMonth];
|
|
5387
|
-
|
|
5388
|
-
if (days > daysInCurrentMonth-newDate.getDate()) {
|
|
5389
|
-
// we spill over to next month
|
|
5390
|
-
days -= (daysInCurrentMonth-newDate.getDate()+1);
|
|
5391
|
-
newDate.setDate(1);
|
|
5392
|
-
if (currentMonth < 11) {
|
|
5393
|
-
newDate.setMonth(currentMonth+1)
|
|
5394
|
-
} else {
|
|
5395
|
-
newDate.setMonth(0);
|
|
5396
|
-
newDate.setFullYear(newDate.getFullYear()+1);
|
|
5397
|
-
}
|
|
5398
|
-
} else {
|
|
5399
|
-
// we stay in current month
|
|
5400
|
-
newDate.setDate(newDate.getDate()+days);
|
|
5401
|
-
return newDate;
|
|
5402
|
-
}
|
|
5403
|
-
}
|
|
5404
|
-
|
|
5405
|
-
return newDate;
|
|
5406
|
-
};
|
|
5407
|
-
|
|
5408
|
-
|
|
5409
|
-
|
|
5410
|
-
|
|
5411
|
-
|
|
5412
|
-
var _strptime = (buf, format, tm) => {
|
|
5413
|
-
// char *strptime(const char *restrict buf, const char *restrict format, struct tm *restrict tm);
|
|
5414
|
-
// http://pubs.opengroup.org/onlinepubs/009695399/functions/strptime.html
|
|
5415
|
-
var pattern = UTF8ToString(format);
|
|
5416
|
-
|
|
5417
|
-
// escape special characters
|
|
5418
|
-
// TODO: not sure we really need to escape all of these in JS regexps
|
|
5419
|
-
var SPECIAL_CHARS = '\\!@#$^&*()+=-[]/{}|:<>?,.';
|
|
5420
|
-
for (var i=0, ii=SPECIAL_CHARS.length; i<ii; ++i) {
|
|
5421
|
-
pattern = pattern.replace(new RegExp('\\'+SPECIAL_CHARS[i], 'g'), '\\'+SPECIAL_CHARS[i]);
|
|
5422
|
-
}
|
|
5423
|
-
|
|
5424
|
-
// reduce number of matchers
|
|
5425
|
-
var EQUIVALENT_MATCHERS = {
|
|
5426
|
-
'A': '%a',
|
|
5427
|
-
'B': '%b',
|
|
5428
|
-
'c': '%a %b %d %H:%M:%S %Y',
|
|
5429
|
-
'D': '%m\\/%d\\/%y',
|
|
5430
|
-
'e': '%d',
|
|
5431
|
-
'F': '%Y-%m-%d',
|
|
5432
|
-
'h': '%b',
|
|
5433
|
-
'R': '%H\\:%M',
|
|
5434
|
-
'r': '%I\\:%M\\:%S\\s%p',
|
|
5435
|
-
'T': '%H\\:%M\\:%S',
|
|
5436
|
-
'x': '%m\\/%d\\/(?:%y|%Y)',
|
|
5437
|
-
'X': '%H\\:%M\\:%S'
|
|
5438
|
-
};
|
|
5439
|
-
// TODO: take care of locale
|
|
5440
|
-
|
|
5441
|
-
var DATE_PATTERNS = {
|
|
5442
|
-
/* weekday name */ 'a': '(?:Sun(?:day)?)|(?:Mon(?:day)?)|(?:Tue(?:sday)?)|(?:Wed(?:nesday)?)|(?:Thu(?:rsday)?)|(?:Fri(?:day)?)|(?:Sat(?:urday)?)',
|
|
5443
|
-
/* month name */ 'b': '(?:Jan(?:uary)?)|(?:Feb(?:ruary)?)|(?:Mar(?:ch)?)|(?:Apr(?:il)?)|May|(?:Jun(?:e)?)|(?:Jul(?:y)?)|(?:Aug(?:ust)?)|(?:Sep(?:tember)?)|(?:Oct(?:ober)?)|(?:Nov(?:ember)?)|(?:Dec(?:ember)?)',
|
|
5444
|
-
/* century */ 'C': '\\d\\d',
|
|
5445
|
-
/* day of month */ 'd': '0[1-9]|[1-9](?!\\d)|1\\d|2\\d|30|31',
|
|
5446
|
-
/* hour (24hr) */ 'H': '\\d(?!\\d)|[0,1]\\d|20|21|22|23',
|
|
5447
|
-
/* hour (12hr) */ 'I': '\\d(?!\\d)|0\\d|10|11|12',
|
|
5448
|
-
/* day of year */ 'j': '00[1-9]|0?[1-9](?!\\d)|0?[1-9]\\d(?!\\d)|[1,2]\\d\\d|3[0-6]\\d',
|
|
5449
|
-
/* month */ 'm': '0[1-9]|[1-9](?!\\d)|10|11|12',
|
|
5450
|
-
/* minutes */ 'M': '0\\d|\\d(?!\\d)|[1-5]\\d',
|
|
5451
|
-
/* whitespace */ 'n': ' ',
|
|
5452
|
-
/* AM/PM */ 'p': 'AM|am|PM|pm|A\\.M\\.|a\\.m\\.|P\\.M\\.|p\\.m\\.',
|
|
5453
|
-
/* seconds */ 'S': '0\\d|\\d(?!\\d)|[1-5]\\d|60',
|
|
5454
|
-
/* week number */ 'U': '0\\d|\\d(?!\\d)|[1-4]\\d|50|51|52|53',
|
|
5455
|
-
/* week number */ 'W': '0\\d|\\d(?!\\d)|[1-4]\\d|50|51|52|53',
|
|
5456
|
-
/* weekday number */ 'w': '[0-6]',
|
|
5457
|
-
/* 2-digit year */ 'y': '\\d\\d',
|
|
5458
|
-
/* 4-digit year */ 'Y': '\\d\\d\\d\\d',
|
|
5459
|
-
/* whitespace */ 't': ' ',
|
|
5460
|
-
/* time zone */ 'z': 'Z|(?:[\\+\\-]\\d\\d:?(?:\\d\\d)?)'
|
|
5461
|
-
};
|
|
5462
|
-
|
|
5463
|
-
var MONTH_NUMBERS = {JAN: 0, FEB: 1, MAR: 2, APR: 3, MAY: 4, JUN: 5, JUL: 6, AUG: 7, SEP: 8, OCT: 9, NOV: 10, DEC: 11};
|
|
5464
|
-
var DAY_NUMBERS_SUN_FIRST = {SUN: 0, MON: 1, TUE: 2, WED: 3, THU: 4, FRI: 5, SAT: 6};
|
|
5465
|
-
var DAY_NUMBERS_MON_FIRST = {MON: 0, TUE: 1, WED: 2, THU: 3, FRI: 4, SAT: 5, SUN: 6};
|
|
5466
|
-
|
|
5467
|
-
var capture = [];
|
|
5468
|
-
var pattern_out = pattern
|
|
5469
|
-
.replace(/%(.)/g, (m, c) => EQUIVALENT_MATCHERS[c] || m)
|
|
5470
|
-
.replace(/%(.)/g, (_, c) => {
|
|
5471
|
-
let pat = DATE_PATTERNS[c];
|
|
5472
|
-
if (pat){
|
|
5473
|
-
capture.push(c);
|
|
5474
|
-
return `(${pat})`;
|
|
5475
|
-
} else {
|
|
5476
|
-
return c;
|
|
5477
|
-
}
|
|
5478
|
-
})
|
|
5479
|
-
.replace( // any number of space or tab characters match zero or more spaces
|
|
5480
|
-
/\s+/g,'\\s*'
|
|
5481
|
-
);
|
|
5482
|
-
|
|
5483
|
-
var matches = new RegExp('^'+pattern_out, "i").exec(UTF8ToString(buf))
|
|
5484
|
-
|
|
5485
|
-
function initDate() {
|
|
5486
|
-
function fixup(value, min, max) {
|
|
5487
|
-
return (typeof value != 'number' || isNaN(value)) ? min : (value>=min ? (value<=max ? value: max): min);
|
|
5488
|
-
};
|
|
5489
|
-
return {
|
|
5490
|
-
year: fixup(HEAP32[(((tm)+(20))>>2)] + 1900 , 1970, 9999),
|
|
5491
|
-
month: fixup(HEAP32[(((tm)+(16))>>2)], 0, 11),
|
|
5492
|
-
day: fixup(HEAP32[(((tm)+(12))>>2)], 1, 31),
|
|
5493
|
-
hour: fixup(HEAP32[(((tm)+(8))>>2)], 0, 23),
|
|
5494
|
-
min: fixup(HEAP32[(((tm)+(4))>>2)], 0, 59),
|
|
5495
|
-
sec: fixup(HEAP32[((tm)>>2)], 0, 59),
|
|
5496
|
-
gmtoff: 0
|
|
5497
|
-
};
|
|
5498
|
-
};
|
|
5499
|
-
|
|
5500
|
-
if (matches) {
|
|
5501
|
-
var date = initDate();
|
|
5502
|
-
var value;
|
|
5503
|
-
|
|
5504
|
-
var getMatch = (symbol) => {
|
|
5505
|
-
var pos = capture.indexOf(symbol);
|
|
5506
|
-
// check if symbol appears in regexp
|
|
5507
|
-
if (pos >= 0) {
|
|
5508
|
-
// return matched value or null (falsy!) for non-matches
|
|
5509
|
-
return matches[pos+1];
|
|
5510
|
-
}
|
|
5511
|
-
return;
|
|
5512
|
-
};
|
|
5513
|
-
|
|
5514
|
-
// seconds
|
|
5515
|
-
if ((value=getMatch('S'))) {
|
|
5516
|
-
date.sec = jstoi_q(value);
|
|
5517
|
-
}
|
|
5518
|
-
|
|
5519
|
-
// minutes
|
|
5520
|
-
if ((value=getMatch('M'))) {
|
|
5521
|
-
date.min = jstoi_q(value);
|
|
5522
|
-
}
|
|
5523
|
-
|
|
5524
|
-
// hours
|
|
5525
|
-
if ((value=getMatch('H'))) {
|
|
5526
|
-
// 24h clock
|
|
5527
|
-
date.hour = jstoi_q(value);
|
|
5528
|
-
} else if ((value = getMatch('I'))) {
|
|
5529
|
-
// AM/PM clock
|
|
5530
|
-
var hour = jstoi_q(value);
|
|
5531
|
-
if ((value=getMatch('p'))) {
|
|
5532
|
-
hour += value.toUpperCase()[0] === 'P' ? 12 : 0;
|
|
5533
|
-
}
|
|
5534
|
-
date.hour = hour;
|
|
5535
|
-
}
|
|
5536
|
-
|
|
5537
|
-
// year
|
|
5538
|
-
if ((value=getMatch('Y'))) {
|
|
5539
|
-
// parse from four-digit year
|
|
5540
|
-
date.year = jstoi_q(value);
|
|
5541
|
-
} else if ((value=getMatch('y'))) {
|
|
5542
|
-
// parse from two-digit year...
|
|
5543
|
-
var year = jstoi_q(value);
|
|
5544
|
-
if ((value=getMatch('C'))) {
|
|
5545
|
-
// ...and century
|
|
5546
|
-
year += jstoi_q(value)*100;
|
|
5547
|
-
} else {
|
|
5548
|
-
// ...and rule-of-thumb
|
|
5549
|
-
year += year<69 ? 2000 : 1900;
|
|
5550
|
-
}
|
|
5551
|
-
date.year = year;
|
|
5552
|
-
}
|
|
5553
|
-
|
|
5554
|
-
// month
|
|
5555
|
-
if ((value=getMatch('m'))) {
|
|
5556
|
-
// parse from month number
|
|
5557
|
-
date.month = jstoi_q(value)-1;
|
|
5558
|
-
} else if ((value=getMatch('b'))) {
|
|
5559
|
-
// parse from month name
|
|
5560
|
-
date.month = MONTH_NUMBERS[value.substring(0,3).toUpperCase()] || 0;
|
|
5561
|
-
// TODO: derive month from day in year+year, week number+day of week+year
|
|
5562
|
-
}
|
|
5563
|
-
|
|
5564
|
-
// day
|
|
5565
|
-
if ((value=getMatch('d'))) {
|
|
5566
|
-
// get day of month directly
|
|
5567
|
-
date.day = jstoi_q(value);
|
|
5568
|
-
} else if ((value=getMatch('j'))) {
|
|
5569
|
-
// get day of month from day of year ...
|
|
5570
|
-
var day = jstoi_q(value);
|
|
5571
|
-
var leapYear = isLeapYear(date.year);
|
|
5572
|
-
for (var month=0; month<12; ++month) {
|
|
5573
|
-
var daysUntilMonth = arraySum(leapYear ? MONTH_DAYS_LEAP : MONTH_DAYS_REGULAR, month-1);
|
|
5574
|
-
if (day<=daysUntilMonth+(leapYear ? MONTH_DAYS_LEAP : MONTH_DAYS_REGULAR)[month]) {
|
|
5575
|
-
date.day = day-daysUntilMonth;
|
|
5576
|
-
}
|
|
5577
|
-
}
|
|
5578
|
-
} else if ((value=getMatch('a'))) {
|
|
5579
|
-
// get day of month from weekday ...
|
|
5580
|
-
var weekDay = value.substring(0,3).toUpperCase();
|
|
5581
|
-
if ((value=getMatch('U'))) {
|
|
5582
|
-
// ... and week number (Sunday being first day of week)
|
|
5583
|
-
// Week number of the year (Sunday as the first day of the week) as a decimal number [00,53].
|
|
5584
|
-
// All days in a new year preceding the first Sunday are considered to be in week 0.
|
|
5585
|
-
var weekDayNumber = DAY_NUMBERS_SUN_FIRST[weekDay];
|
|
5586
|
-
var weekNumber = jstoi_q(value);
|
|
5587
|
-
|
|
5588
|
-
// January 1st
|
|
5589
|
-
var janFirst = new Date(date.year, 0, 1);
|
|
5590
|
-
var endDate;
|
|
5591
|
-
if (janFirst.getDay() === 0) {
|
|
5592
|
-
// Jan 1st is a Sunday, and, hence in the 1st CW
|
|
5593
|
-
endDate = addDays(janFirst, weekDayNumber+7*(weekNumber-1));
|
|
5594
|
-
} else {
|
|
5595
|
-
// Jan 1st is not a Sunday, and, hence still in the 0th CW
|
|
5596
|
-
endDate = addDays(janFirst, 7-janFirst.getDay()+weekDayNumber+7*(weekNumber-1));
|
|
5597
|
-
}
|
|
5598
|
-
date.day = endDate.getDate();
|
|
5599
|
-
date.month = endDate.getMonth();
|
|
5600
|
-
} else if ((value=getMatch('W'))) {
|
|
5601
|
-
// ... and week number (Monday being first day of week)
|
|
5602
|
-
// Week number of the year (Monday as the first day of the week) as a decimal number [00,53].
|
|
5603
|
-
// All days in a new year preceding the first Monday are considered to be in week 0.
|
|
5604
|
-
var weekDayNumber = DAY_NUMBERS_MON_FIRST[weekDay];
|
|
5605
|
-
var weekNumber = jstoi_q(value);
|
|
5606
|
-
|
|
5607
|
-
// January 1st
|
|
5608
|
-
var janFirst = new Date(date.year, 0, 1);
|
|
5609
|
-
var endDate;
|
|
5610
|
-
if (janFirst.getDay()===1) {
|
|
5611
|
-
// Jan 1st is a Monday, and, hence in the 1st CW
|
|
5612
|
-
endDate = addDays(janFirst, weekDayNumber+7*(weekNumber-1));
|
|
5613
|
-
} else {
|
|
5614
|
-
// Jan 1st is not a Monday, and, hence still in the 0th CW
|
|
5615
|
-
endDate = addDays(janFirst, 7-janFirst.getDay()+1+weekDayNumber+7*(weekNumber-1));
|
|
5616
|
-
}
|
|
5617
|
-
|
|
5618
|
-
date.day = endDate.getDate();
|
|
5619
|
-
date.month = endDate.getMonth();
|
|
5620
|
-
}
|
|
5621
|
-
}
|
|
5622
|
-
|
|
5623
|
-
// time zone
|
|
5624
|
-
if ((value = getMatch('z'))) {
|
|
5625
|
-
// GMT offset as either 'Z' or +-HH:MM or +-HH or +-HHMM
|
|
5626
|
-
if (value.toLowerCase() === 'z'){
|
|
5627
|
-
date.gmtoff = 0;
|
|
5628
|
-
} else {
|
|
5629
|
-
var match = value.match(/^((?:\-|\+)\d\d):?(\d\d)?/);
|
|
5630
|
-
date.gmtoff = match[1] * 3600;
|
|
5631
|
-
if (match[2]) {
|
|
5632
|
-
date.gmtoff += date.gmtoff >0 ? match[2] * 60 : -match[2] * 60
|
|
5633
|
-
}
|
|
5634
|
-
}
|
|
5635
|
-
}
|
|
5636
|
-
|
|
5637
|
-
/*
|
|
5638
|
-
tm_sec int seconds after the minute 0-61*
|
|
5639
|
-
tm_min int minutes after the hour 0-59
|
|
5640
|
-
tm_hour int hours since midnight 0-23
|
|
5641
|
-
tm_mday int day of the month 1-31
|
|
5642
|
-
tm_mon int months since January 0-11
|
|
5643
|
-
tm_year int years since 1900
|
|
5644
|
-
tm_wday int days since Sunday 0-6
|
|
5645
|
-
tm_yday int days since January 1 0-365
|
|
5646
|
-
tm_isdst int Daylight Saving Time flag
|
|
5647
|
-
tm_gmtoff long offset from GMT (seconds)
|
|
5648
|
-
*/
|
|
5649
|
-
|
|
5650
|
-
var fullDate = new Date(date.year, date.month, date.day, date.hour, date.min, date.sec, 0);
|
|
5651
|
-
HEAP32[((tm)>>2)] = fullDate.getSeconds();
|
|
5652
|
-
HEAP32[(((tm)+(4))>>2)] = fullDate.getMinutes();
|
|
5653
|
-
HEAP32[(((tm)+(8))>>2)] = fullDate.getHours();
|
|
5654
|
-
HEAP32[(((tm)+(12))>>2)] = fullDate.getDate();
|
|
5655
|
-
HEAP32[(((tm)+(16))>>2)] = fullDate.getMonth();
|
|
5656
|
-
HEAP32[(((tm)+(20))>>2)] = fullDate.getFullYear()-1900;
|
|
5657
|
-
HEAP32[(((tm)+(24))>>2)] = fullDate.getDay();
|
|
5658
|
-
HEAP32[(((tm)+(28))>>2)] = arraySum(isLeapYear(fullDate.getFullYear()) ? MONTH_DAYS_LEAP : MONTH_DAYS_REGULAR, fullDate.getMonth()-1)+fullDate.getDate()-1;
|
|
5659
|
-
HEAP32[(((tm)+(32))>>2)] = 0;
|
|
5660
|
-
HEAP32[(((tm)+(36))>>2)] = date.gmtoff;
|
|
5661
|
-
|
|
5662
|
-
// we need to convert the matched sequence into an integer array to take care of UTF-8 characters > 0x7F
|
|
5663
|
-
// TODO: not sure that intArrayFromString handles all unicode characters correctly
|
|
5664
|
-
return buf+intArrayFromString(matches[0]).length-1;
|
|
5665
|
-
}
|
|
5666
|
-
|
|
5667
|
-
return 0;
|
|
5668
|
-
};
|
|
5669
|
-
|
|
5670
5368
|
FS.createPreloadedFile = FS_createPreloadedFile;
|
|
5671
5369
|
FS.staticInit();
|
|
5672
5370
|
// Set module methods based on EXPORTED_RUNTIME_METHODS
|
|
@@ -5774,9 +5472,7 @@ var wasmImports = {
|
|
|
5774
5472
|
/** @export */
|
|
5775
5473
|
getaddrinfo: _getaddrinfo,
|
|
5776
5474
|
/** @export */
|
|
5777
|
-
memory: wasmMemory
|
|
5778
|
-
/** @export */
|
|
5779
|
-
strptime: _strptime
|
|
5475
|
+
memory: wasmMemory
|
|
5780
5476
|
};
|
|
5781
5477
|
var wasmExports;
|
|
5782
5478
|
createWasm();
|
package/sqlite3-node.mjs
CHANGED
|
@@ -5481,308 +5481,6 @@ async function createWasm() {
|
|
|
5481
5481
|
return 0;
|
|
5482
5482
|
};
|
|
5483
5483
|
|
|
5484
|
-
|
|
5485
|
-
var arraySum = (array, index) => {
|
|
5486
|
-
var sum = 0;
|
|
5487
|
-
for (var i = 0; i <= index; sum += array[i++]) {
|
|
5488
|
-
// no-op
|
|
5489
|
-
}
|
|
5490
|
-
return sum;
|
|
5491
|
-
};
|
|
5492
|
-
|
|
5493
|
-
|
|
5494
|
-
var MONTH_DAYS_LEAP = [31,29,31,30,31,30,31,31,30,31,30,31];
|
|
5495
|
-
|
|
5496
|
-
var MONTH_DAYS_REGULAR = [31,28,31,30,31,30,31,31,30,31,30,31];
|
|
5497
|
-
var addDays = (date, days) => {
|
|
5498
|
-
var newDate = new Date(date.getTime());
|
|
5499
|
-
while (days > 0) {
|
|
5500
|
-
var leap = isLeapYear(newDate.getFullYear());
|
|
5501
|
-
var currentMonth = newDate.getMonth();
|
|
5502
|
-
var daysInCurrentMonth = (leap ? MONTH_DAYS_LEAP : MONTH_DAYS_REGULAR)[currentMonth];
|
|
5503
|
-
|
|
5504
|
-
if (days > daysInCurrentMonth-newDate.getDate()) {
|
|
5505
|
-
// we spill over to next month
|
|
5506
|
-
days -= (daysInCurrentMonth-newDate.getDate()+1);
|
|
5507
|
-
newDate.setDate(1);
|
|
5508
|
-
if (currentMonth < 11) {
|
|
5509
|
-
newDate.setMonth(currentMonth+1)
|
|
5510
|
-
} else {
|
|
5511
|
-
newDate.setMonth(0);
|
|
5512
|
-
newDate.setFullYear(newDate.getFullYear()+1);
|
|
5513
|
-
}
|
|
5514
|
-
} else {
|
|
5515
|
-
// we stay in current month
|
|
5516
|
-
newDate.setDate(newDate.getDate()+days);
|
|
5517
|
-
return newDate;
|
|
5518
|
-
}
|
|
5519
|
-
}
|
|
5520
|
-
|
|
5521
|
-
return newDate;
|
|
5522
|
-
};
|
|
5523
|
-
|
|
5524
|
-
|
|
5525
|
-
|
|
5526
|
-
|
|
5527
|
-
|
|
5528
|
-
var _strptime = (buf, format, tm) => {
|
|
5529
|
-
// char *strptime(const char *restrict buf, const char *restrict format, struct tm *restrict tm);
|
|
5530
|
-
// http://pubs.opengroup.org/onlinepubs/009695399/functions/strptime.html
|
|
5531
|
-
var pattern = UTF8ToString(format);
|
|
5532
|
-
|
|
5533
|
-
// escape special characters
|
|
5534
|
-
// TODO: not sure we really need to escape all of these in JS regexps
|
|
5535
|
-
var SPECIAL_CHARS = '\\!@#$^&*()+=-[]/{}|:<>?,.';
|
|
5536
|
-
for (var i=0, ii=SPECIAL_CHARS.length; i<ii; ++i) {
|
|
5537
|
-
pattern = pattern.replace(new RegExp('\\'+SPECIAL_CHARS[i], 'g'), '\\'+SPECIAL_CHARS[i]);
|
|
5538
|
-
}
|
|
5539
|
-
|
|
5540
|
-
// reduce number of matchers
|
|
5541
|
-
var EQUIVALENT_MATCHERS = {
|
|
5542
|
-
'A': '%a',
|
|
5543
|
-
'B': '%b',
|
|
5544
|
-
'c': '%a %b %d %H:%M:%S %Y',
|
|
5545
|
-
'D': '%m\\/%d\\/%y',
|
|
5546
|
-
'e': '%d',
|
|
5547
|
-
'F': '%Y-%m-%d',
|
|
5548
|
-
'h': '%b',
|
|
5549
|
-
'R': '%H\\:%M',
|
|
5550
|
-
'r': '%I\\:%M\\:%S\\s%p',
|
|
5551
|
-
'T': '%H\\:%M\\:%S',
|
|
5552
|
-
'x': '%m\\/%d\\/(?:%y|%Y)',
|
|
5553
|
-
'X': '%H\\:%M\\:%S'
|
|
5554
|
-
};
|
|
5555
|
-
// TODO: take care of locale
|
|
5556
|
-
|
|
5557
|
-
var DATE_PATTERNS = {
|
|
5558
|
-
/* weekday name */ 'a': '(?:Sun(?:day)?)|(?:Mon(?:day)?)|(?:Tue(?:sday)?)|(?:Wed(?:nesday)?)|(?:Thu(?:rsday)?)|(?:Fri(?:day)?)|(?:Sat(?:urday)?)',
|
|
5559
|
-
/* month name */ 'b': '(?:Jan(?:uary)?)|(?:Feb(?:ruary)?)|(?:Mar(?:ch)?)|(?:Apr(?:il)?)|May|(?:Jun(?:e)?)|(?:Jul(?:y)?)|(?:Aug(?:ust)?)|(?:Sep(?:tember)?)|(?:Oct(?:ober)?)|(?:Nov(?:ember)?)|(?:Dec(?:ember)?)',
|
|
5560
|
-
/* century */ 'C': '\\d\\d',
|
|
5561
|
-
/* day of month */ 'd': '0[1-9]|[1-9](?!\\d)|1\\d|2\\d|30|31',
|
|
5562
|
-
/* hour (24hr) */ 'H': '\\d(?!\\d)|[0,1]\\d|20|21|22|23',
|
|
5563
|
-
/* hour (12hr) */ 'I': '\\d(?!\\d)|0\\d|10|11|12',
|
|
5564
|
-
/* day of year */ 'j': '00[1-9]|0?[1-9](?!\\d)|0?[1-9]\\d(?!\\d)|[1,2]\\d\\d|3[0-6]\\d',
|
|
5565
|
-
/* month */ 'm': '0[1-9]|[1-9](?!\\d)|10|11|12',
|
|
5566
|
-
/* minutes */ 'M': '0\\d|\\d(?!\\d)|[1-5]\\d',
|
|
5567
|
-
/* whitespace */ 'n': ' ',
|
|
5568
|
-
/* AM/PM */ 'p': 'AM|am|PM|pm|A\\.M\\.|a\\.m\\.|P\\.M\\.|p\\.m\\.',
|
|
5569
|
-
/* seconds */ 'S': '0\\d|\\d(?!\\d)|[1-5]\\d|60',
|
|
5570
|
-
/* week number */ 'U': '0\\d|\\d(?!\\d)|[1-4]\\d|50|51|52|53',
|
|
5571
|
-
/* week number */ 'W': '0\\d|\\d(?!\\d)|[1-4]\\d|50|51|52|53',
|
|
5572
|
-
/* weekday number */ 'w': '[0-6]',
|
|
5573
|
-
/* 2-digit year */ 'y': '\\d\\d',
|
|
5574
|
-
/* 4-digit year */ 'Y': '\\d\\d\\d\\d',
|
|
5575
|
-
/* whitespace */ 't': ' ',
|
|
5576
|
-
/* time zone */ 'z': 'Z|(?:[\\+\\-]\\d\\d:?(?:\\d\\d)?)'
|
|
5577
|
-
};
|
|
5578
|
-
|
|
5579
|
-
var MONTH_NUMBERS = {JAN: 0, FEB: 1, MAR: 2, APR: 3, MAY: 4, JUN: 5, JUL: 6, AUG: 7, SEP: 8, OCT: 9, NOV: 10, DEC: 11};
|
|
5580
|
-
var DAY_NUMBERS_SUN_FIRST = {SUN: 0, MON: 1, TUE: 2, WED: 3, THU: 4, FRI: 5, SAT: 6};
|
|
5581
|
-
var DAY_NUMBERS_MON_FIRST = {MON: 0, TUE: 1, WED: 2, THU: 3, FRI: 4, SAT: 5, SUN: 6};
|
|
5582
|
-
|
|
5583
|
-
var capture = [];
|
|
5584
|
-
var pattern_out = pattern
|
|
5585
|
-
.replace(/%(.)/g, (m, c) => EQUIVALENT_MATCHERS[c] || m)
|
|
5586
|
-
.replace(/%(.)/g, (_, c) => {
|
|
5587
|
-
let pat = DATE_PATTERNS[c];
|
|
5588
|
-
if (pat){
|
|
5589
|
-
capture.push(c);
|
|
5590
|
-
return `(${pat})`;
|
|
5591
|
-
} else {
|
|
5592
|
-
return c;
|
|
5593
|
-
}
|
|
5594
|
-
})
|
|
5595
|
-
.replace( // any number of space or tab characters match zero or more spaces
|
|
5596
|
-
/\s+/g,'\\s*'
|
|
5597
|
-
);
|
|
5598
|
-
|
|
5599
|
-
var matches = new RegExp('^'+pattern_out, "i").exec(UTF8ToString(buf))
|
|
5600
|
-
|
|
5601
|
-
function initDate() {
|
|
5602
|
-
function fixup(value, min, max) {
|
|
5603
|
-
return (typeof value != 'number' || isNaN(value)) ? min : (value>=min ? (value<=max ? value: max): min);
|
|
5604
|
-
};
|
|
5605
|
-
return {
|
|
5606
|
-
year: fixup(HEAP32[(((tm)+(20))>>2)] + 1900 , 1970, 9999),
|
|
5607
|
-
month: fixup(HEAP32[(((tm)+(16))>>2)], 0, 11),
|
|
5608
|
-
day: fixup(HEAP32[(((tm)+(12))>>2)], 1, 31),
|
|
5609
|
-
hour: fixup(HEAP32[(((tm)+(8))>>2)], 0, 23),
|
|
5610
|
-
min: fixup(HEAP32[(((tm)+(4))>>2)], 0, 59),
|
|
5611
|
-
sec: fixup(HEAP32[((tm)>>2)], 0, 59),
|
|
5612
|
-
gmtoff: 0
|
|
5613
|
-
};
|
|
5614
|
-
};
|
|
5615
|
-
|
|
5616
|
-
if (matches) {
|
|
5617
|
-
var date = initDate();
|
|
5618
|
-
var value;
|
|
5619
|
-
|
|
5620
|
-
var getMatch = (symbol) => {
|
|
5621
|
-
var pos = capture.indexOf(symbol);
|
|
5622
|
-
// check if symbol appears in regexp
|
|
5623
|
-
if (pos >= 0) {
|
|
5624
|
-
// return matched value or null (falsy!) for non-matches
|
|
5625
|
-
return matches[pos+1];
|
|
5626
|
-
}
|
|
5627
|
-
return;
|
|
5628
|
-
};
|
|
5629
|
-
|
|
5630
|
-
// seconds
|
|
5631
|
-
if ((value=getMatch('S'))) {
|
|
5632
|
-
date.sec = jstoi_q(value);
|
|
5633
|
-
}
|
|
5634
|
-
|
|
5635
|
-
// minutes
|
|
5636
|
-
if ((value=getMatch('M'))) {
|
|
5637
|
-
date.min = jstoi_q(value);
|
|
5638
|
-
}
|
|
5639
|
-
|
|
5640
|
-
// hours
|
|
5641
|
-
if ((value=getMatch('H'))) {
|
|
5642
|
-
// 24h clock
|
|
5643
|
-
date.hour = jstoi_q(value);
|
|
5644
|
-
} else if ((value = getMatch('I'))) {
|
|
5645
|
-
// AM/PM clock
|
|
5646
|
-
var hour = jstoi_q(value);
|
|
5647
|
-
if ((value=getMatch('p'))) {
|
|
5648
|
-
hour += value.toUpperCase()[0] === 'P' ? 12 : 0;
|
|
5649
|
-
}
|
|
5650
|
-
date.hour = hour;
|
|
5651
|
-
}
|
|
5652
|
-
|
|
5653
|
-
// year
|
|
5654
|
-
if ((value=getMatch('Y'))) {
|
|
5655
|
-
// parse from four-digit year
|
|
5656
|
-
date.year = jstoi_q(value);
|
|
5657
|
-
} else if ((value=getMatch('y'))) {
|
|
5658
|
-
// parse from two-digit year...
|
|
5659
|
-
var year = jstoi_q(value);
|
|
5660
|
-
if ((value=getMatch('C'))) {
|
|
5661
|
-
// ...and century
|
|
5662
|
-
year += jstoi_q(value)*100;
|
|
5663
|
-
} else {
|
|
5664
|
-
// ...and rule-of-thumb
|
|
5665
|
-
year += year<69 ? 2000 : 1900;
|
|
5666
|
-
}
|
|
5667
|
-
date.year = year;
|
|
5668
|
-
}
|
|
5669
|
-
|
|
5670
|
-
// month
|
|
5671
|
-
if ((value=getMatch('m'))) {
|
|
5672
|
-
// parse from month number
|
|
5673
|
-
date.month = jstoi_q(value)-1;
|
|
5674
|
-
} else if ((value=getMatch('b'))) {
|
|
5675
|
-
// parse from month name
|
|
5676
|
-
date.month = MONTH_NUMBERS[value.substring(0,3).toUpperCase()] || 0;
|
|
5677
|
-
// TODO: derive month from day in year+year, week number+day of week+year
|
|
5678
|
-
}
|
|
5679
|
-
|
|
5680
|
-
// day
|
|
5681
|
-
if ((value=getMatch('d'))) {
|
|
5682
|
-
// get day of month directly
|
|
5683
|
-
date.day = jstoi_q(value);
|
|
5684
|
-
} else if ((value=getMatch('j'))) {
|
|
5685
|
-
// get day of month from day of year ...
|
|
5686
|
-
var day = jstoi_q(value);
|
|
5687
|
-
var leapYear = isLeapYear(date.year);
|
|
5688
|
-
for (var month=0; month<12; ++month) {
|
|
5689
|
-
var daysUntilMonth = arraySum(leapYear ? MONTH_DAYS_LEAP : MONTH_DAYS_REGULAR, month-1);
|
|
5690
|
-
if (day<=daysUntilMonth+(leapYear ? MONTH_DAYS_LEAP : MONTH_DAYS_REGULAR)[month]) {
|
|
5691
|
-
date.day = day-daysUntilMonth;
|
|
5692
|
-
}
|
|
5693
|
-
}
|
|
5694
|
-
} else if ((value=getMatch('a'))) {
|
|
5695
|
-
// get day of month from weekday ...
|
|
5696
|
-
var weekDay = value.substring(0,3).toUpperCase();
|
|
5697
|
-
if ((value=getMatch('U'))) {
|
|
5698
|
-
// ... and week number (Sunday being first day of week)
|
|
5699
|
-
// Week number of the year (Sunday as the first day of the week) as a decimal number [00,53].
|
|
5700
|
-
// All days in a new year preceding the first Sunday are considered to be in week 0.
|
|
5701
|
-
var weekDayNumber = DAY_NUMBERS_SUN_FIRST[weekDay];
|
|
5702
|
-
var weekNumber = jstoi_q(value);
|
|
5703
|
-
|
|
5704
|
-
// January 1st
|
|
5705
|
-
var janFirst = new Date(date.year, 0, 1);
|
|
5706
|
-
var endDate;
|
|
5707
|
-
if (janFirst.getDay() === 0) {
|
|
5708
|
-
// Jan 1st is a Sunday, and, hence in the 1st CW
|
|
5709
|
-
endDate = addDays(janFirst, weekDayNumber+7*(weekNumber-1));
|
|
5710
|
-
} else {
|
|
5711
|
-
// Jan 1st is not a Sunday, and, hence still in the 0th CW
|
|
5712
|
-
endDate = addDays(janFirst, 7-janFirst.getDay()+weekDayNumber+7*(weekNumber-1));
|
|
5713
|
-
}
|
|
5714
|
-
date.day = endDate.getDate();
|
|
5715
|
-
date.month = endDate.getMonth();
|
|
5716
|
-
} else if ((value=getMatch('W'))) {
|
|
5717
|
-
// ... and week number (Monday being first day of week)
|
|
5718
|
-
// Week number of the year (Monday as the first day of the week) as a decimal number [00,53].
|
|
5719
|
-
// All days in a new year preceding the first Monday are considered to be in week 0.
|
|
5720
|
-
var weekDayNumber = DAY_NUMBERS_MON_FIRST[weekDay];
|
|
5721
|
-
var weekNumber = jstoi_q(value);
|
|
5722
|
-
|
|
5723
|
-
// January 1st
|
|
5724
|
-
var janFirst = new Date(date.year, 0, 1);
|
|
5725
|
-
var endDate;
|
|
5726
|
-
if (janFirst.getDay()===1) {
|
|
5727
|
-
// Jan 1st is a Monday, and, hence in the 1st CW
|
|
5728
|
-
endDate = addDays(janFirst, weekDayNumber+7*(weekNumber-1));
|
|
5729
|
-
} else {
|
|
5730
|
-
// Jan 1st is not a Monday, and, hence still in the 0th CW
|
|
5731
|
-
endDate = addDays(janFirst, 7-janFirst.getDay()+1+weekDayNumber+7*(weekNumber-1));
|
|
5732
|
-
}
|
|
5733
|
-
|
|
5734
|
-
date.day = endDate.getDate();
|
|
5735
|
-
date.month = endDate.getMonth();
|
|
5736
|
-
}
|
|
5737
|
-
}
|
|
5738
|
-
|
|
5739
|
-
// time zone
|
|
5740
|
-
if ((value = getMatch('z'))) {
|
|
5741
|
-
// GMT offset as either 'Z' or +-HH:MM or +-HH or +-HHMM
|
|
5742
|
-
if (value.toLowerCase() === 'z'){
|
|
5743
|
-
date.gmtoff = 0;
|
|
5744
|
-
} else {
|
|
5745
|
-
var match = value.match(/^((?:\-|\+)\d\d):?(\d\d)?/);
|
|
5746
|
-
date.gmtoff = match[1] * 3600;
|
|
5747
|
-
if (match[2]) {
|
|
5748
|
-
date.gmtoff += date.gmtoff >0 ? match[2] * 60 : -match[2] * 60
|
|
5749
|
-
}
|
|
5750
|
-
}
|
|
5751
|
-
}
|
|
5752
|
-
|
|
5753
|
-
/*
|
|
5754
|
-
tm_sec int seconds after the minute 0-61*
|
|
5755
|
-
tm_min int minutes after the hour 0-59
|
|
5756
|
-
tm_hour int hours since midnight 0-23
|
|
5757
|
-
tm_mday int day of the month 1-31
|
|
5758
|
-
tm_mon int months since January 0-11
|
|
5759
|
-
tm_year int years since 1900
|
|
5760
|
-
tm_wday int days since Sunday 0-6
|
|
5761
|
-
tm_yday int days since January 1 0-365
|
|
5762
|
-
tm_isdst int Daylight Saving Time flag
|
|
5763
|
-
tm_gmtoff long offset from GMT (seconds)
|
|
5764
|
-
*/
|
|
5765
|
-
|
|
5766
|
-
var fullDate = new Date(date.year, date.month, date.day, date.hour, date.min, date.sec, 0);
|
|
5767
|
-
HEAP32[((tm)>>2)] = fullDate.getSeconds();
|
|
5768
|
-
HEAP32[(((tm)+(4))>>2)] = fullDate.getMinutes();
|
|
5769
|
-
HEAP32[(((tm)+(8))>>2)] = fullDate.getHours();
|
|
5770
|
-
HEAP32[(((tm)+(12))>>2)] = fullDate.getDate();
|
|
5771
|
-
HEAP32[(((tm)+(16))>>2)] = fullDate.getMonth();
|
|
5772
|
-
HEAP32[(((tm)+(20))>>2)] = fullDate.getFullYear()-1900;
|
|
5773
|
-
HEAP32[(((tm)+(24))>>2)] = fullDate.getDay();
|
|
5774
|
-
HEAP32[(((tm)+(28))>>2)] = arraySum(isLeapYear(fullDate.getFullYear()) ? MONTH_DAYS_LEAP : MONTH_DAYS_REGULAR, fullDate.getMonth()-1)+fullDate.getDate()-1;
|
|
5775
|
-
HEAP32[(((tm)+(32))>>2)] = 0;
|
|
5776
|
-
HEAP32[(((tm)+(36))>>2)] = date.gmtoff;
|
|
5777
|
-
|
|
5778
|
-
// we need to convert the matched sequence into an integer array to take care of UTF-8 characters > 0x7F
|
|
5779
|
-
// TODO: not sure that intArrayFromString handles all unicode characters correctly
|
|
5780
|
-
return buf+intArrayFromString(matches[0]).length-1;
|
|
5781
|
-
}
|
|
5782
|
-
|
|
5783
|
-
return 0;
|
|
5784
|
-
};
|
|
5785
|
-
|
|
5786
5484
|
FS.createPreloadedFile = FS_createPreloadedFile;
|
|
5787
5485
|
FS.staticInit();
|
|
5788
5486
|
// Set module methods based on EXPORTED_RUNTIME_METHODS
|
|
@@ -5890,9 +5588,7 @@ var wasmImports = {
|
|
|
5890
5588
|
/** @export */
|
|
5891
5589
|
getaddrinfo: _getaddrinfo,
|
|
5892
5590
|
/** @export */
|
|
5893
|
-
memory: wasmMemory
|
|
5894
|
-
/** @export */
|
|
5895
|
-
strptime: _strptime
|
|
5591
|
+
memory: wasmMemory
|
|
5896
5592
|
};
|
|
5897
5593
|
var wasmExports;
|
|
5898
5594
|
createWasm();
|
package/sqlite3.mjs
CHANGED
|
@@ -5456,308 +5456,6 @@ async function createWasm() {
|
|
|
5456
5456
|
return 0;
|
|
5457
5457
|
};
|
|
5458
5458
|
|
|
5459
|
-
|
|
5460
|
-
var arraySum = (array, index) => {
|
|
5461
|
-
var sum = 0;
|
|
5462
|
-
for (var i = 0; i <= index; sum += array[i++]) {
|
|
5463
|
-
// no-op
|
|
5464
|
-
}
|
|
5465
|
-
return sum;
|
|
5466
|
-
};
|
|
5467
|
-
|
|
5468
|
-
|
|
5469
|
-
var MONTH_DAYS_LEAP = [31,29,31,30,31,30,31,31,30,31,30,31];
|
|
5470
|
-
|
|
5471
|
-
var MONTH_DAYS_REGULAR = [31,28,31,30,31,30,31,31,30,31,30,31];
|
|
5472
|
-
var addDays = (date, days) => {
|
|
5473
|
-
var newDate = new Date(date.getTime());
|
|
5474
|
-
while (days > 0) {
|
|
5475
|
-
var leap = isLeapYear(newDate.getFullYear());
|
|
5476
|
-
var currentMonth = newDate.getMonth();
|
|
5477
|
-
var daysInCurrentMonth = (leap ? MONTH_DAYS_LEAP : MONTH_DAYS_REGULAR)[currentMonth];
|
|
5478
|
-
|
|
5479
|
-
if (days > daysInCurrentMonth-newDate.getDate()) {
|
|
5480
|
-
// we spill over to next month
|
|
5481
|
-
days -= (daysInCurrentMonth-newDate.getDate()+1);
|
|
5482
|
-
newDate.setDate(1);
|
|
5483
|
-
if (currentMonth < 11) {
|
|
5484
|
-
newDate.setMonth(currentMonth+1)
|
|
5485
|
-
} else {
|
|
5486
|
-
newDate.setMonth(0);
|
|
5487
|
-
newDate.setFullYear(newDate.getFullYear()+1);
|
|
5488
|
-
}
|
|
5489
|
-
} else {
|
|
5490
|
-
// we stay in current month
|
|
5491
|
-
newDate.setDate(newDate.getDate()+days);
|
|
5492
|
-
return newDate;
|
|
5493
|
-
}
|
|
5494
|
-
}
|
|
5495
|
-
|
|
5496
|
-
return newDate;
|
|
5497
|
-
};
|
|
5498
|
-
|
|
5499
|
-
|
|
5500
|
-
|
|
5501
|
-
|
|
5502
|
-
|
|
5503
|
-
var _strptime = (buf, format, tm) => {
|
|
5504
|
-
// char *strptime(const char *restrict buf, const char *restrict format, struct tm *restrict tm);
|
|
5505
|
-
// http://pubs.opengroup.org/onlinepubs/009695399/functions/strptime.html
|
|
5506
|
-
var pattern = UTF8ToString(format);
|
|
5507
|
-
|
|
5508
|
-
// escape special characters
|
|
5509
|
-
// TODO: not sure we really need to escape all of these in JS regexps
|
|
5510
|
-
var SPECIAL_CHARS = '\\!@#$^&*()+=-[]/{}|:<>?,.';
|
|
5511
|
-
for (var i=0, ii=SPECIAL_CHARS.length; i<ii; ++i) {
|
|
5512
|
-
pattern = pattern.replace(new RegExp('\\'+SPECIAL_CHARS[i], 'g'), '\\'+SPECIAL_CHARS[i]);
|
|
5513
|
-
}
|
|
5514
|
-
|
|
5515
|
-
// reduce number of matchers
|
|
5516
|
-
var EQUIVALENT_MATCHERS = {
|
|
5517
|
-
'A': '%a',
|
|
5518
|
-
'B': '%b',
|
|
5519
|
-
'c': '%a %b %d %H:%M:%S %Y',
|
|
5520
|
-
'D': '%m\\/%d\\/%y',
|
|
5521
|
-
'e': '%d',
|
|
5522
|
-
'F': '%Y-%m-%d',
|
|
5523
|
-
'h': '%b',
|
|
5524
|
-
'R': '%H\\:%M',
|
|
5525
|
-
'r': '%I\\:%M\\:%S\\s%p',
|
|
5526
|
-
'T': '%H\\:%M\\:%S',
|
|
5527
|
-
'x': '%m\\/%d\\/(?:%y|%Y)',
|
|
5528
|
-
'X': '%H\\:%M\\:%S'
|
|
5529
|
-
};
|
|
5530
|
-
// TODO: take care of locale
|
|
5531
|
-
|
|
5532
|
-
var DATE_PATTERNS = {
|
|
5533
|
-
/* weekday name */ 'a': '(?:Sun(?:day)?)|(?:Mon(?:day)?)|(?:Tue(?:sday)?)|(?:Wed(?:nesday)?)|(?:Thu(?:rsday)?)|(?:Fri(?:day)?)|(?:Sat(?:urday)?)',
|
|
5534
|
-
/* month name */ 'b': '(?:Jan(?:uary)?)|(?:Feb(?:ruary)?)|(?:Mar(?:ch)?)|(?:Apr(?:il)?)|May|(?:Jun(?:e)?)|(?:Jul(?:y)?)|(?:Aug(?:ust)?)|(?:Sep(?:tember)?)|(?:Oct(?:ober)?)|(?:Nov(?:ember)?)|(?:Dec(?:ember)?)',
|
|
5535
|
-
/* century */ 'C': '\\d\\d',
|
|
5536
|
-
/* day of month */ 'd': '0[1-9]|[1-9](?!\\d)|1\\d|2\\d|30|31',
|
|
5537
|
-
/* hour (24hr) */ 'H': '\\d(?!\\d)|[0,1]\\d|20|21|22|23',
|
|
5538
|
-
/* hour (12hr) */ 'I': '\\d(?!\\d)|0\\d|10|11|12',
|
|
5539
|
-
/* day of year */ 'j': '00[1-9]|0?[1-9](?!\\d)|0?[1-9]\\d(?!\\d)|[1,2]\\d\\d|3[0-6]\\d',
|
|
5540
|
-
/* month */ 'm': '0[1-9]|[1-9](?!\\d)|10|11|12',
|
|
5541
|
-
/* minutes */ 'M': '0\\d|\\d(?!\\d)|[1-5]\\d',
|
|
5542
|
-
/* whitespace */ 'n': ' ',
|
|
5543
|
-
/* AM/PM */ 'p': 'AM|am|PM|pm|A\\.M\\.|a\\.m\\.|P\\.M\\.|p\\.m\\.',
|
|
5544
|
-
/* seconds */ 'S': '0\\d|\\d(?!\\d)|[1-5]\\d|60',
|
|
5545
|
-
/* week number */ 'U': '0\\d|\\d(?!\\d)|[1-4]\\d|50|51|52|53',
|
|
5546
|
-
/* week number */ 'W': '0\\d|\\d(?!\\d)|[1-4]\\d|50|51|52|53',
|
|
5547
|
-
/* weekday number */ 'w': '[0-6]',
|
|
5548
|
-
/* 2-digit year */ 'y': '\\d\\d',
|
|
5549
|
-
/* 4-digit year */ 'Y': '\\d\\d\\d\\d',
|
|
5550
|
-
/* whitespace */ 't': ' ',
|
|
5551
|
-
/* time zone */ 'z': 'Z|(?:[\\+\\-]\\d\\d:?(?:\\d\\d)?)'
|
|
5552
|
-
};
|
|
5553
|
-
|
|
5554
|
-
var MONTH_NUMBERS = {JAN: 0, FEB: 1, MAR: 2, APR: 3, MAY: 4, JUN: 5, JUL: 6, AUG: 7, SEP: 8, OCT: 9, NOV: 10, DEC: 11};
|
|
5555
|
-
var DAY_NUMBERS_SUN_FIRST = {SUN: 0, MON: 1, TUE: 2, WED: 3, THU: 4, FRI: 5, SAT: 6};
|
|
5556
|
-
var DAY_NUMBERS_MON_FIRST = {MON: 0, TUE: 1, WED: 2, THU: 3, FRI: 4, SAT: 5, SUN: 6};
|
|
5557
|
-
|
|
5558
|
-
var capture = [];
|
|
5559
|
-
var pattern_out = pattern
|
|
5560
|
-
.replace(/%(.)/g, (m, c) => EQUIVALENT_MATCHERS[c] || m)
|
|
5561
|
-
.replace(/%(.)/g, (_, c) => {
|
|
5562
|
-
let pat = DATE_PATTERNS[c];
|
|
5563
|
-
if (pat){
|
|
5564
|
-
capture.push(c);
|
|
5565
|
-
return `(${pat})`;
|
|
5566
|
-
} else {
|
|
5567
|
-
return c;
|
|
5568
|
-
}
|
|
5569
|
-
})
|
|
5570
|
-
.replace( // any number of space or tab characters match zero or more spaces
|
|
5571
|
-
/\s+/g,'\\s*'
|
|
5572
|
-
);
|
|
5573
|
-
|
|
5574
|
-
var matches = new RegExp('^'+pattern_out, "i").exec(UTF8ToString(buf))
|
|
5575
|
-
|
|
5576
|
-
function initDate() {
|
|
5577
|
-
function fixup(value, min, max) {
|
|
5578
|
-
return (typeof value != 'number' || isNaN(value)) ? min : (value>=min ? (value<=max ? value: max): min);
|
|
5579
|
-
};
|
|
5580
|
-
return {
|
|
5581
|
-
year: fixup(HEAP32[(((tm)+(20))>>2)] + 1900 , 1970, 9999),
|
|
5582
|
-
month: fixup(HEAP32[(((tm)+(16))>>2)], 0, 11),
|
|
5583
|
-
day: fixup(HEAP32[(((tm)+(12))>>2)], 1, 31),
|
|
5584
|
-
hour: fixup(HEAP32[(((tm)+(8))>>2)], 0, 23),
|
|
5585
|
-
min: fixup(HEAP32[(((tm)+(4))>>2)], 0, 59),
|
|
5586
|
-
sec: fixup(HEAP32[((tm)>>2)], 0, 59),
|
|
5587
|
-
gmtoff: 0
|
|
5588
|
-
};
|
|
5589
|
-
};
|
|
5590
|
-
|
|
5591
|
-
if (matches) {
|
|
5592
|
-
var date = initDate();
|
|
5593
|
-
var value;
|
|
5594
|
-
|
|
5595
|
-
var getMatch = (symbol) => {
|
|
5596
|
-
var pos = capture.indexOf(symbol);
|
|
5597
|
-
// check if symbol appears in regexp
|
|
5598
|
-
if (pos >= 0) {
|
|
5599
|
-
// return matched value or null (falsy!) for non-matches
|
|
5600
|
-
return matches[pos+1];
|
|
5601
|
-
}
|
|
5602
|
-
return;
|
|
5603
|
-
};
|
|
5604
|
-
|
|
5605
|
-
// seconds
|
|
5606
|
-
if ((value=getMatch('S'))) {
|
|
5607
|
-
date.sec = jstoi_q(value);
|
|
5608
|
-
}
|
|
5609
|
-
|
|
5610
|
-
// minutes
|
|
5611
|
-
if ((value=getMatch('M'))) {
|
|
5612
|
-
date.min = jstoi_q(value);
|
|
5613
|
-
}
|
|
5614
|
-
|
|
5615
|
-
// hours
|
|
5616
|
-
if ((value=getMatch('H'))) {
|
|
5617
|
-
// 24h clock
|
|
5618
|
-
date.hour = jstoi_q(value);
|
|
5619
|
-
} else if ((value = getMatch('I'))) {
|
|
5620
|
-
// AM/PM clock
|
|
5621
|
-
var hour = jstoi_q(value);
|
|
5622
|
-
if ((value=getMatch('p'))) {
|
|
5623
|
-
hour += value.toUpperCase()[0] === 'P' ? 12 : 0;
|
|
5624
|
-
}
|
|
5625
|
-
date.hour = hour;
|
|
5626
|
-
}
|
|
5627
|
-
|
|
5628
|
-
// year
|
|
5629
|
-
if ((value=getMatch('Y'))) {
|
|
5630
|
-
// parse from four-digit year
|
|
5631
|
-
date.year = jstoi_q(value);
|
|
5632
|
-
} else if ((value=getMatch('y'))) {
|
|
5633
|
-
// parse from two-digit year...
|
|
5634
|
-
var year = jstoi_q(value);
|
|
5635
|
-
if ((value=getMatch('C'))) {
|
|
5636
|
-
// ...and century
|
|
5637
|
-
year += jstoi_q(value)*100;
|
|
5638
|
-
} else {
|
|
5639
|
-
// ...and rule-of-thumb
|
|
5640
|
-
year += year<69 ? 2000 : 1900;
|
|
5641
|
-
}
|
|
5642
|
-
date.year = year;
|
|
5643
|
-
}
|
|
5644
|
-
|
|
5645
|
-
// month
|
|
5646
|
-
if ((value=getMatch('m'))) {
|
|
5647
|
-
// parse from month number
|
|
5648
|
-
date.month = jstoi_q(value)-1;
|
|
5649
|
-
} else if ((value=getMatch('b'))) {
|
|
5650
|
-
// parse from month name
|
|
5651
|
-
date.month = MONTH_NUMBERS[value.substring(0,3).toUpperCase()] || 0;
|
|
5652
|
-
// TODO: derive month from day in year+year, week number+day of week+year
|
|
5653
|
-
}
|
|
5654
|
-
|
|
5655
|
-
// day
|
|
5656
|
-
if ((value=getMatch('d'))) {
|
|
5657
|
-
// get day of month directly
|
|
5658
|
-
date.day = jstoi_q(value);
|
|
5659
|
-
} else if ((value=getMatch('j'))) {
|
|
5660
|
-
// get day of month from day of year ...
|
|
5661
|
-
var day = jstoi_q(value);
|
|
5662
|
-
var leapYear = isLeapYear(date.year);
|
|
5663
|
-
for (var month=0; month<12; ++month) {
|
|
5664
|
-
var daysUntilMonth = arraySum(leapYear ? MONTH_DAYS_LEAP : MONTH_DAYS_REGULAR, month-1);
|
|
5665
|
-
if (day<=daysUntilMonth+(leapYear ? MONTH_DAYS_LEAP : MONTH_DAYS_REGULAR)[month]) {
|
|
5666
|
-
date.day = day-daysUntilMonth;
|
|
5667
|
-
}
|
|
5668
|
-
}
|
|
5669
|
-
} else if ((value=getMatch('a'))) {
|
|
5670
|
-
// get day of month from weekday ...
|
|
5671
|
-
var weekDay = value.substring(0,3).toUpperCase();
|
|
5672
|
-
if ((value=getMatch('U'))) {
|
|
5673
|
-
// ... and week number (Sunday being first day of week)
|
|
5674
|
-
// Week number of the year (Sunday as the first day of the week) as a decimal number [00,53].
|
|
5675
|
-
// All days in a new year preceding the first Sunday are considered to be in week 0.
|
|
5676
|
-
var weekDayNumber = DAY_NUMBERS_SUN_FIRST[weekDay];
|
|
5677
|
-
var weekNumber = jstoi_q(value);
|
|
5678
|
-
|
|
5679
|
-
// January 1st
|
|
5680
|
-
var janFirst = new Date(date.year, 0, 1);
|
|
5681
|
-
var endDate;
|
|
5682
|
-
if (janFirst.getDay() === 0) {
|
|
5683
|
-
// Jan 1st is a Sunday, and, hence in the 1st CW
|
|
5684
|
-
endDate = addDays(janFirst, weekDayNumber+7*(weekNumber-1));
|
|
5685
|
-
} else {
|
|
5686
|
-
// Jan 1st is not a Sunday, and, hence still in the 0th CW
|
|
5687
|
-
endDate = addDays(janFirst, 7-janFirst.getDay()+weekDayNumber+7*(weekNumber-1));
|
|
5688
|
-
}
|
|
5689
|
-
date.day = endDate.getDate();
|
|
5690
|
-
date.month = endDate.getMonth();
|
|
5691
|
-
} else if ((value=getMatch('W'))) {
|
|
5692
|
-
// ... and week number (Monday being first day of week)
|
|
5693
|
-
// Week number of the year (Monday as the first day of the week) as a decimal number [00,53].
|
|
5694
|
-
// All days in a new year preceding the first Monday are considered to be in week 0.
|
|
5695
|
-
var weekDayNumber = DAY_NUMBERS_MON_FIRST[weekDay];
|
|
5696
|
-
var weekNumber = jstoi_q(value);
|
|
5697
|
-
|
|
5698
|
-
// January 1st
|
|
5699
|
-
var janFirst = new Date(date.year, 0, 1);
|
|
5700
|
-
var endDate;
|
|
5701
|
-
if (janFirst.getDay()===1) {
|
|
5702
|
-
// Jan 1st is a Monday, and, hence in the 1st CW
|
|
5703
|
-
endDate = addDays(janFirst, weekDayNumber+7*(weekNumber-1));
|
|
5704
|
-
} else {
|
|
5705
|
-
// Jan 1st is not a Monday, and, hence still in the 0th CW
|
|
5706
|
-
endDate = addDays(janFirst, 7-janFirst.getDay()+1+weekDayNumber+7*(weekNumber-1));
|
|
5707
|
-
}
|
|
5708
|
-
|
|
5709
|
-
date.day = endDate.getDate();
|
|
5710
|
-
date.month = endDate.getMonth();
|
|
5711
|
-
}
|
|
5712
|
-
}
|
|
5713
|
-
|
|
5714
|
-
// time zone
|
|
5715
|
-
if ((value = getMatch('z'))) {
|
|
5716
|
-
// GMT offset as either 'Z' or +-HH:MM or +-HH or +-HHMM
|
|
5717
|
-
if (value.toLowerCase() === 'z'){
|
|
5718
|
-
date.gmtoff = 0;
|
|
5719
|
-
} else {
|
|
5720
|
-
var match = value.match(/^((?:\-|\+)\d\d):?(\d\d)?/);
|
|
5721
|
-
date.gmtoff = match[1] * 3600;
|
|
5722
|
-
if (match[2]) {
|
|
5723
|
-
date.gmtoff += date.gmtoff >0 ? match[2] * 60 : -match[2] * 60
|
|
5724
|
-
}
|
|
5725
|
-
}
|
|
5726
|
-
}
|
|
5727
|
-
|
|
5728
|
-
/*
|
|
5729
|
-
tm_sec int seconds after the minute 0-61*
|
|
5730
|
-
tm_min int minutes after the hour 0-59
|
|
5731
|
-
tm_hour int hours since midnight 0-23
|
|
5732
|
-
tm_mday int day of the month 1-31
|
|
5733
|
-
tm_mon int months since January 0-11
|
|
5734
|
-
tm_year int years since 1900
|
|
5735
|
-
tm_wday int days since Sunday 0-6
|
|
5736
|
-
tm_yday int days since January 1 0-365
|
|
5737
|
-
tm_isdst int Daylight Saving Time flag
|
|
5738
|
-
tm_gmtoff long offset from GMT (seconds)
|
|
5739
|
-
*/
|
|
5740
|
-
|
|
5741
|
-
var fullDate = new Date(date.year, date.month, date.day, date.hour, date.min, date.sec, 0);
|
|
5742
|
-
HEAP32[((tm)>>2)] = fullDate.getSeconds();
|
|
5743
|
-
HEAP32[(((tm)+(4))>>2)] = fullDate.getMinutes();
|
|
5744
|
-
HEAP32[(((tm)+(8))>>2)] = fullDate.getHours();
|
|
5745
|
-
HEAP32[(((tm)+(12))>>2)] = fullDate.getDate();
|
|
5746
|
-
HEAP32[(((tm)+(16))>>2)] = fullDate.getMonth();
|
|
5747
|
-
HEAP32[(((tm)+(20))>>2)] = fullDate.getFullYear()-1900;
|
|
5748
|
-
HEAP32[(((tm)+(24))>>2)] = fullDate.getDay();
|
|
5749
|
-
HEAP32[(((tm)+(28))>>2)] = arraySum(isLeapYear(fullDate.getFullYear()) ? MONTH_DAYS_LEAP : MONTH_DAYS_REGULAR, fullDate.getMonth()-1)+fullDate.getDate()-1;
|
|
5750
|
-
HEAP32[(((tm)+(32))>>2)] = 0;
|
|
5751
|
-
HEAP32[(((tm)+(36))>>2)] = date.gmtoff;
|
|
5752
|
-
|
|
5753
|
-
// we need to convert the matched sequence into an integer array to take care of UTF-8 characters > 0x7F
|
|
5754
|
-
// TODO: not sure that intArrayFromString handles all unicode characters correctly
|
|
5755
|
-
return buf+intArrayFromString(matches[0]).length-1;
|
|
5756
|
-
}
|
|
5757
|
-
|
|
5758
|
-
return 0;
|
|
5759
|
-
};
|
|
5760
|
-
|
|
5761
5459
|
FS.createPreloadedFile = FS_createPreloadedFile;
|
|
5762
5460
|
FS.staticInit();
|
|
5763
5461
|
// Set module methods based on EXPORTED_RUNTIME_METHODS
|
|
@@ -5865,9 +5563,7 @@ var wasmImports = {
|
|
|
5865
5563
|
/** @export */
|
|
5866
5564
|
getaddrinfo: _getaddrinfo,
|
|
5867
5565
|
/** @export */
|
|
5868
|
-
memory: wasmMemory
|
|
5869
|
-
/** @export */
|
|
5870
|
-
strptime: _strptime
|
|
5566
|
+
memory: wasmMemory
|
|
5871
5567
|
};
|
|
5872
5568
|
var wasmExports;
|
|
5873
5569
|
createWasm();
|
package/sqlite3.wasm
CHANGED
|
Binary file
|