dateblock 2.0.0__tar.gz → 2.1.0__tar.gz
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.
- {dateblock-2.0.0 → dateblock-2.1.0}/ChangeLog +52 -0
- {dateblock-2.0.0 → dateblock-2.1.0}/PKG-INFO +237 -7
- {dateblock-2.0.0 → dateblock-2.1.0}/README.md +236 -6
- {dateblock-2.0.0 → dateblock-2.1.0}/configure.ac +1 -1
- {dateblock-2.0.0 → dateblock-2.1.0}/python/_dateblock.cpp +361 -48
- {dateblock-2.0.0 → dateblock-2.1.0}/python/dateblock/__init__.py +10 -2
- dateblock-2.1.0/python/dateblock/_wait.py +49 -0
- {dateblock-2.0.0 → dateblock-2.1.0}/python/dateblock.egg-info/PKG-INFO +237 -7
- {dateblock-2.0.0 → dateblock-2.1.0}/python/dateblock.egg-info/SOURCES.txt +1 -0
- {dateblock-2.0.0 → dateblock-2.1.0}/python/tests/test_dateblock.py +378 -1
- {dateblock-2.0.0 → dateblock-2.1.0}/src/Date.cpp +566 -68
- {dateblock-2.0.0 → dateblock-2.1.0}/src/Date.h +30 -2
- {dateblock-2.0.0 → dateblock-2.1.0}/AUTHORS +0 -0
- {dateblock-2.0.0 → dateblock-2.1.0}/COPYING +0 -0
- {dateblock-2.0.0 → dateblock-2.1.0}/LICENSE +0 -0
- {dateblock-2.0.0 → dateblock-2.1.0}/MANIFEST.in +0 -0
- {dateblock-2.0.0 → dateblock-2.1.0}/pyproject.toml +0 -0
- {dateblock-2.0.0 → dateblock-2.1.0}/python/dateblock.egg-info/dependency_links.txt +0 -0
- {dateblock-2.0.0 → dateblock-2.1.0}/python/dateblock.egg-info/top_level.txt +0 -0
- {dateblock-2.0.0 → dateblock-2.1.0}/setup.cfg +0 -0
- {dateblock-2.0.0 → dateblock-2.1.0}/setup.py +0 -0
|
@@ -1,6 +1,58 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
All notable changes to this project will be documented in this file.
|
|
3
3
|
|
|
4
|
+
## [2.1.0] - 2026-10-31
|
|
5
|
+
### Added
|
|
6
|
+
- PHP bindings (PHP 8.0 and newer): `dateblock('0 0 9', ref: $tokyo)`
|
|
7
|
+
returns a `DateTimeImmutable`, reading the cron in the timezone of `$ref`.
|
|
8
|
+
Install with `pie install caronc/dateblock` or the `php-dateblock`
|
|
9
|
+
package.
|
|
10
|
+
- Node.js bindings (Node.js 20 and newer): `await dateblock('0 0 9',
|
|
11
|
+
{ timeZone: 'Asia/Tokyo' })` waits without blocking, and `next()` only
|
|
12
|
+
works the time out. Install with `npm install @caronc/dateblock`.
|
|
13
|
+
- Python: `await dateblock.wait('0 0 9')` waits with asyncio, without
|
|
14
|
+
blocking other tasks; it takes the same `cron`, `ref` and `isc` as
|
|
15
|
+
`dateblock()`.
|
|
16
|
+
- Month and weekday names, as crontab allows: `0 0 9 * * Mon-Fri`,
|
|
17
|
+
`-m Jan,Jul`. A backwards range of names (`Sat-Sun`) is refused, since
|
|
18
|
+
it would mean every day.
|
|
19
|
+
- A day of the week of 7 means Sunday, as in crontab (`Fri-7`).
|
|
20
|
+
- crontab's shortcuts: `@hourly`, `@daily` (`@midnight`), `@weekly`,
|
|
21
|
+
`@monthly` and `@yearly` (`@annually`), optionally followed by a drift
|
|
22
|
+
(`@daily +30`).
|
|
23
|
+
- List the next few times without waiting, to check a schedule:
|
|
24
|
+
`dateblock -C 5 -i -c '0 9 * * Mon-Fri'`, and in the bindings
|
|
25
|
+
`dateblock.upcoming()` (Python), `dateblock_upcoming()` (PHP) and
|
|
26
|
+
`upcoming()` (Node.js). Up to 1000; just the next one unless told
|
|
27
|
+
otherwise.
|
|
28
|
+
|
|
29
|
+
### Changed
|
|
30
|
+
- Node.js: the add-on now comes ready built for Linux (x64 and arm64, glibc
|
|
31
|
+
and musl/Alpine), macOS (Intel and Apple silicon) and Windows (x64 and
|
|
32
|
+
arm64), so `npm install @caronc/dateblock` compiles nothing and has no
|
|
33
|
+
install step to approve on npm 12. On any other computer, build it once
|
|
34
|
+
with `npm explore @caronc/dateblock -- npm run build`.
|
|
35
|
+
- macOS and Windows wait with the system's own timer, set to the exact
|
|
36
|
+
moment, instead of waking every second: it still fires on time if the
|
|
37
|
+
computer sleeps or the clock is changed. As a safety net the clock is
|
|
38
|
+
also checked once an hour, a minute before the moment, and every second
|
|
39
|
+
over the final minute. Linux is unchanged (it already slept until the
|
|
40
|
+
exact time).
|
|
41
|
+
|
|
42
|
+
### Fixed
|
|
43
|
+
- Node.js on Windows: a syntax error's message could come out garbled (or
|
|
44
|
+
empty), since the add-on read it after it had been freed.
|
|
45
|
+
- Error messages write every byte of the input that isn't plain printable
|
|
46
|
+
text as `\xNN` (not just control characters), so nothing in a bad cron
|
|
47
|
+
can upset a terminal or a log.
|
|
48
|
+
- The Python, PHP and Node.js bindings only copy the start of a huge cron
|
|
49
|
+
string before refusing it, instead of all of it.
|
|
50
|
+
- Python: when the clocks go back and a time happens twice, the second one
|
|
51
|
+
comes back with `fold=1`, so its `timestamp()` is right.
|
|
52
|
+
- Node.js: a wait that spans the computer sleeping (or the clock being
|
|
53
|
+
changed) now ends within a minute of the right moment, instead of late
|
|
54
|
+
by however long the computer slept.
|
|
55
|
+
|
|
4
56
|
## [2.0.0] - 2026-10-26
|
|
5
57
|
The project is now called **dateblock** (it used to be datetools).
|
|
6
58
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dateblock
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.1.0
|
|
4
4
|
Summary: Block (sleep) until a cron-style moment in time
|
|
5
5
|
Home-page: https://github.com/caronc/dateblock
|
|
6
6
|
Author: Chris Caron
|
|
@@ -49,6 +49,10 @@ Dynamic: summary
|
|
|
49
49
|
[](https://www.paypal.com/donate/?hosted_button_id=CR6YF7KLQWQ5E)
|
|
50
50
|
[](https://pypi.org/project/dateblock/)
|
|
51
51
|
[](https://pypi.org/project/dateblock/)
|
|
52
|
+
[](https://www.npmjs.com/package/@caronc/dateblock)
|
|
53
|
+
[](https://www.npmjs.com/package/@caronc/dateblock)
|
|
54
|
+
[](https://packagist.org/packages/caronc/dateblock)
|
|
55
|
+
[](https://packagist.org/packages/caronc/dateblock)
|
|
52
56
|
|
|
53
57
|
Dateblock
|
|
54
58
|
=========
|
|
@@ -61,8 +65,8 @@ does not (refering to /etc/crontab style). Dateblock specifically offers the abi
|
|
|
61
65
|
to wake/unblock on a _specific second_ and/or _drift_ for certain period afterwards
|
|
62
66
|
your calculated time is met (kind of like combining _sleep_ and _ICS Cron_ into one).
|
|
63
67
|
|
|
64
|
-
Python bindings are additionally included supporting
|
|
65
|
-
|
|
68
|
+
Python, PHP and Node.js bindings are additionally included, supporting the
|
|
69
|
+
standard date and time objects of each language!
|
|
66
70
|
|
|
67
71
|
## Quick Start
|
|
68
72
|
The `dateblock` command is a C++ tool; install it from the distribution
|
|
@@ -83,6 +87,18 @@ The Python library is on PyPI (Linux, macOS and Windows):
|
|
|
83
87
|
pip install dateblock
|
|
84
88
|
```
|
|
85
89
|
|
|
90
|
+
The PHP extension installs with [PIE](https://github.com/php/pie) (Linux and
|
|
91
|
+
macOS with a 64-bit `time_t`, PHP 8.0 and newer):
|
|
92
|
+
```bash
|
|
93
|
+
pie install caronc/dateblock
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
The Node.js package is on npm (Node.js 20 and newer, on a system with a
|
|
97
|
+
64-bit `time_t`):
|
|
98
|
+
```bash
|
|
99
|
+
npm install @caronc/dateblock
|
|
100
|
+
```
|
|
101
|
+
|
|
86
102
|
Packages for Fedora, RHEL/CentOS/Alma/Rocky 9 and 10, Debian and Arch Linux
|
|
87
103
|
can be built from this repository; see [Installation](#installation).
|
|
88
104
|
|
|
@@ -99,12 +115,14 @@ __Allowed options__:
|
|
|
99
115
|
-n [ --minute ] arg Minute (0-59)
|
|
100
116
|
-o [ --hour ] arg Hour (0-23)
|
|
101
117
|
-d [ --dom ] arg Day of Month (1-31)
|
|
102
|
-
-m [ --month ] arg Month (1-12
|
|
103
|
-
-w [ --dow ] arg Day of Week (0-6
|
|
118
|
+
-m [ --month ] arg Month (1-12 or Jan-Dec)
|
|
119
|
+
-w [ --dow ] arg Day of Week (0-6 or Sun-Sat; Sun=0 or 7)
|
|
104
120
|
-c [ --cron ] arg Cron string formatting
|
|
105
121
|
-x [ --drift ] arg Additional drift time (in seconds).
|
|
106
122
|
-z [ --timezone ] arg Timezone to read the schedule in (ie:
|
|
107
123
|
America/Toronto); defaults to this computer's.
|
|
124
|
+
-C [ --count ] arg List the next N times (1-1000) instead of
|
|
125
|
+
waiting; nothing is run.
|
|
108
126
|
|
|
109
127
|
Anything after the options (or after --) is a command to run once the
|
|
110
128
|
time is reached.
|
|
@@ -116,6 +134,10 @@ A variety of syntax is accepted by this tool such as:
|
|
|
116
134
|
*/x (or /x) (Modulus) where 'x' is represented numerically.
|
|
117
135
|
x-y (or y-x) (Range) where 'x' and 'y' are are represented numerically.
|
|
118
136
|
x,y (Separator) where 'x' and 'y' are are represented numerically.
|
|
137
|
+
Mon-Fri, Jan (Names) the month and the day of the week can be written
|
|
138
|
+
as names (Jan-Dec and Sun-Sat, in any case).
|
|
139
|
+
7 (Sunday) as in crontab, a day of the week of 7 is Sunday
|
|
140
|
+
too, so Fri-7 is Friday to Sunday.
|
|
119
141
|
```
|
|
120
142
|
|
|
121
143
|
__Note__: With the exception of the drift option (+), all variations of the syntax
|
|
@@ -129,7 +151,7 @@ __Note__: With the exception of the drift option (+), all variations of the synt
|
|
|
129
151
|
The __--cron__(__-c__) switch allows one to specify the standard cron formatting:
|
|
130
152
|
```
|
|
131
153
|
drift time ----------------------------------------------+
|
|
132
|
-
day of week (0 -
|
|
154
|
+
day of week (0 - 7) (Sunday=0 or 7) ------------------+ |
|
|
133
155
|
month (1 - 12) ------------------------------------+ | |
|
|
134
156
|
day of month (1 - 31) --------------------------+ | | |
|
|
135
157
|
hour (0 - 23) -------------------------------+ | | | |
|
|
@@ -143,6 +165,16 @@ Substitute an asterisk (*) as a placeholder for arguments you are not
|
|
|
143
165
|
interested in. Asterisks are automatically placed in strings missing all 6
|
|
144
166
|
arguments (separated by white space).
|
|
145
167
|
|
|
168
|
+
The crontab shortcuts work too (with or without `--isc`). Without `--isc`
|
|
169
|
+
one can be followed by a drift (ie: `@daily +30`):
|
|
170
|
+
```
|
|
171
|
+
@hourly the start of every hour
|
|
172
|
+
@daily (or @midnight) every day at 00:00
|
|
173
|
+
@weekly every Sunday at 00:00
|
|
174
|
+
@monthly the 1st of every month at 00:00
|
|
175
|
+
@yearly (or @annually) every January 1st at 00:00
|
|
176
|
+
```
|
|
177
|
+
|
|
146
178
|
The __--isc__ (__-i__) switch makes the cron interpretation equivalent to
|
|
147
179
|
what it is today (ISC stands for Internet Systems Consortium). Hence:
|
|
148
180
|
```
|
|
@@ -152,7 +184,7 @@ what it is today (ISC stands for Internet Systems Consortium). Hence:
|
|
|
152
184
|
| +----------------------- hour (0 - 23)
|
|
153
185
|
| | +----------------- day of month (1 - 31)
|
|
154
186
|
| | | +----------- month (1 - 12)
|
|
155
|
-
| | | | +----- day of week (0 -
|
|
187
|
+
| | | | +----- day of week (0 - 7) (Sunday=0 or 7)
|
|
156
188
|
| | | | |
|
|
157
189
|
- - - - -
|
|
158
190
|
* * * * *
|
|
@@ -177,6 +209,25 @@ Current Time : 2026-10-24 22:05:00 JST (Sat)
|
|
|
177
209
|
Block Until : 2026-10-25 09:00:00 JST (Sun)
|
|
178
210
|
```
|
|
179
211
|
|
|
212
|
+
### Listing the next few times:
|
|
213
|
+
__--count__ (__-C__) lists the next few times a schedule matches, without
|
|
214
|
+
waiting. It is the quickest way to check a schedule, and with __--isc__
|
|
215
|
+
(__-i__) a handy way to learn how a crontab entry behaves:
|
|
216
|
+
```bash
|
|
217
|
+
dateblock -C 5 -i -c "0 9 * * Mon-Fri"
|
|
218
|
+
Current Time : 2026-10-30 16:53:37 (Fri)
|
|
219
|
+
Next Times : 2026-11-02 09:00:00 (Mon)
|
|
220
|
+
2026-11-03 09:00:00 (Tue)
|
|
221
|
+
2026-11-04 09:00:00 (Wed)
|
|
222
|
+
2026-11-05 09:00:00 (Thu)
|
|
223
|
+
2026-11-06 09:00:00 (Fri)
|
|
224
|
+
```
|
|
225
|
+
- Up to 1000 times can be listed. The first is the one dateblock would
|
|
226
|
+
wait for.
|
|
227
|
+
- Nothing is run: a command after the options is only shown.
|
|
228
|
+
- In the rare case that no later time exists (ie: past the last date the
|
|
229
|
+
computer can show), the list just ends early and a note says so.
|
|
230
|
+
|
|
180
231
|
### Running a command:
|
|
181
232
|
Put a command (and its arguments) after the options, and dateblock runs it
|
|
182
233
|
once the time is reached:
|
|
@@ -354,6 +405,141 @@ A few things worth knowing:
|
|
|
354
405
|
- While blocking, other Python threads keep running and Ctrl-C
|
|
355
406
|
(`KeyboardInterrupt`) works as expected.
|
|
356
407
|
|
|
408
|
+
With asyncio, use `await dateblock.wait(...)` instead. It takes the same
|
|
409
|
+
`cron`, `ref` and `isc` arguments, returns the same `datetime`, and lets
|
|
410
|
+
your other tasks keep running while it waits (no thread needed):
|
|
411
|
+
```python
|
|
412
|
+
import asyncio
|
|
413
|
+
import dateblock
|
|
414
|
+
|
|
415
|
+
async def main():
|
|
416
|
+
# Wait for the next 20 minute mark
|
|
417
|
+
result = await dateblock.wait("* /20")
|
|
418
|
+
print("Unblocked at %s" % result.strftime("%Y-%m-%d %H:%M:%S"))
|
|
419
|
+
|
|
420
|
+
# Stop waiting early: give up after 10 seconds
|
|
421
|
+
try:
|
|
422
|
+
await asyncio.wait_for(dateblock.wait("0 0 9"), 10)
|
|
423
|
+
except asyncio.TimeoutError:
|
|
424
|
+
print("Gave up waiting")
|
|
425
|
+
|
|
426
|
+
asyncio.run(main())
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
- Cancelling the task (or a timeout, as above) stops the wait.
|
|
430
|
+
- A long wait checks the real clock once a minute, so it still ends on
|
|
431
|
+
time if the computer sleeps or the clock is changed. That costs very
|
|
432
|
+
little, but if you keep thousands of waits going at once, prefer one
|
|
433
|
+
task that waits and then hands the work out.
|
|
434
|
+
|
|
435
|
+
To see the next few times without waiting, use `dateblock.upcoming()`. It
|
|
436
|
+
takes the same `cron`, `ref` and `isc`, plus a `count` (just the next one
|
|
437
|
+
unless given, at most 1000), and returns a tuple of `datetime`s, earliest first:
|
|
438
|
+
```python
|
|
439
|
+
import dateblock
|
|
440
|
+
|
|
441
|
+
for when in dateblock.upcoming("0 9 * * Mon-Fri", 3, isc=True):
|
|
442
|
+
print(when.strftime("%a %Y-%m-%d %H:%M"))
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
- The `datetime`s are the same kind `dateblock()` returns: aware ones in
|
|
446
|
+
`ref`'s own timezone, otherwise naive ones in this computer's.
|
|
447
|
+
- When the clocks go back and a time happens twice, both are listed; the
|
|
448
|
+
second naive one has `fold=1`, so its `timestamp()` is right.
|
|
449
|
+
- The tuple is shorter than `count` only when no later time can be shown
|
|
450
|
+
(ie: past the year 9999).
|
|
451
|
+
- `dateblock.COUNT_DEFAULT` (1) and `dateblock.COUNT_MAX` (1000) hold the
|
|
452
|
+
limits.
|
|
453
|
+
|
|
454
|
+
### DateBlock PHP Bindings
|
|
455
|
+
The PHP extension adds a `dateblock()` function that works the same way
|
|
456
|
+
(and `dateblock_upcoming()`, below):
|
|
457
|
+
```php
|
|
458
|
+
<?php
|
|
459
|
+
// Returns the moment it will unblock at (a DateTimeImmutable)
|
|
460
|
+
$result = dateblock('* /20', block: false);
|
|
461
|
+
echo 'Blocking until ', $result->format('Y-m-d H:i:s'), "\n";
|
|
462
|
+
dateblock('* /20');
|
|
463
|
+
|
|
464
|
+
// Work it out from another moment (a DateTime, DateTimeImmutable or
|
|
465
|
+
// seconds since the epoch)
|
|
466
|
+
$result = dateblock('* /20', false, new DateTimeImmutable('-4 days'));
|
|
467
|
+
$result = dateblock('/5', false, 13424236);
|
|
468
|
+
|
|
469
|
+
// A regular crontab entry: the start of each minute
|
|
470
|
+
$result = dateblock('* * * * *', isc: true);
|
|
471
|
+
|
|
472
|
+
// Timezones: the cron is read in the timezone of the reference, and the
|
|
473
|
+
// result comes back in that same timezone. This waits for 9:00 in Tokyo.
|
|
474
|
+
$tokyo = new DateTimeImmutable('now', new DateTimeZone('Asia/Tokyo'));
|
|
475
|
+
$result = dateblock('0 0 9', ref: $tokyo);
|
|
476
|
+
```
|
|
477
|
+
|
|
478
|
+
A few things worth knowing:
|
|
479
|
+
- Without a `DateTime`/`DateTimeImmutable` reference, the cron is read in
|
|
480
|
+
PHP's default timezone (`date.timezone`, see
|
|
481
|
+
`date_default_timezone_get()`), not the computer's.
|
|
482
|
+
- An invalid cron string throws a `ValueError` saying what is wrong; a cron
|
|
483
|
+
that can never happen (such as February 31st) throws a
|
|
484
|
+
`RuntimeException`.
|
|
485
|
+
- Signal handlers set with `pcntl_signal()` run once it returns; Ctrl-C
|
|
486
|
+
still ends the script straight away unless a handler is set for it.
|
|
487
|
+
|
|
488
|
+
`dateblock_upcoming()` lists the next few times without waiting. It takes
|
|
489
|
+
the same `$cron`, `$ref` and `$isc`, plus a `$count` (just the next one
|
|
490
|
+
unless given, at most 1000), and returns an array of `DateTimeImmutable`, earliest first,
|
|
491
|
+
in the same timezone `dateblock()` would use:
|
|
492
|
+
```php
|
|
493
|
+
<?php
|
|
494
|
+
foreach (dateblock_upcoming('0 9 * * Mon-Fri', 3, isc: true) as $when) {
|
|
495
|
+
echo $when->format('D Y-m-d H:i'), "\n";
|
|
496
|
+
}
|
|
497
|
+
```
|
|
498
|
+
The array is shorter than `$count` only when no later time exists. The
|
|
499
|
+
limits are in `DATEBLOCK_COUNT_DEFAULT` and `DATEBLOCK_COUNT_MAX`.
|
|
500
|
+
|
|
501
|
+
### DateBlock Node.js Bindings
|
|
502
|
+
The Node.js package waits without blocking: `dateblock()` returns a promise,
|
|
503
|
+
and the rest of your program keeps running in the meantime.
|
|
504
|
+
```javascript
|
|
505
|
+
import { dateblock, next, upcoming } from '@caronc/dateblock';
|
|
506
|
+
// or, in CommonJS: const { dateblock, next, upcoming } = require('@caronc/dateblock');
|
|
507
|
+
|
|
508
|
+
// When is the next 20 minute mark? (a Date; nothing waits)
|
|
509
|
+
const when = next('* /20');
|
|
510
|
+
|
|
511
|
+
// Wait for it
|
|
512
|
+
await dateblock('* /20');
|
|
513
|
+
|
|
514
|
+
// Work it out from another moment (a Date, or milliseconds since the epoch)
|
|
515
|
+
next('* /20', { ref: new Date(Date.now() - 4 * 86400000) });
|
|
516
|
+
|
|
517
|
+
// A regular crontab entry: the start of each minute
|
|
518
|
+
next('* * * * *', { isc: true });
|
|
519
|
+
|
|
520
|
+
// Timezones: 9:00 in Tokyo, whatever timezone this computer is in
|
|
521
|
+
await dateblock('0 0 9', { timeZone: 'Asia/Tokyo' });
|
|
522
|
+
|
|
523
|
+
// The next 3 weekday mornings (an array of Dates; nothing waits)
|
|
524
|
+
upcoming('0 9 * * Mon-Fri', { isc: true, count: 3 });
|
|
525
|
+
|
|
526
|
+
// Stop waiting early with an AbortSignal
|
|
527
|
+
const controller = new AbortController();
|
|
528
|
+
dateblock('0 0 9', { signal: controller.signal }).catch(() => {});
|
|
529
|
+
controller.abort();
|
|
530
|
+
```
|
|
531
|
+
|
|
532
|
+
A few things worth knowing:
|
|
533
|
+
- Without `timeZone`, the cron is read in the same timezone JavaScript's
|
|
534
|
+
`Date` uses.
|
|
535
|
+
- An invalid cron string throws a `SyntaxError` saying what is wrong; a cron
|
|
536
|
+
that can never happen (such as February 31st), an unknown timezone or a
|
|
537
|
+
reference too far away throws a `RangeError`.
|
|
538
|
+
- `upcoming()` takes `next()`'s options plus `count` (just the next one
|
|
539
|
+
unless given, at most 1000; also exported as `COUNT_DEFAULT` and `COUNT_MAX`). The array
|
|
540
|
+
is shorter than `count` only when no later time fits in a `Date`.
|
|
541
|
+
- TypeScript types are included.
|
|
542
|
+
|
|
357
543
|
## Installation
|
|
358
544
|
### From PyPI (the Python library)
|
|
359
545
|
```bash
|
|
@@ -364,6 +550,36 @@ is compiled straight into it, so nothing else is needed). The `dateblock`
|
|
|
364
550
|
command is the C++ tool; install it from the packages or build it from
|
|
365
551
|
source as shown below.
|
|
366
552
|
|
|
553
|
+
### With PIE (the PHP extension)
|
|
554
|
+
```bash
|
|
555
|
+
pie install caronc/dateblock
|
|
556
|
+
```
|
|
557
|
+
PIE builds the extension on your computer (the C++ code is compiled straight
|
|
558
|
+
into it), so it needs a C++ compiler and the PHP development files (ie:
|
|
559
|
+
`php-devel` or `php-dev`), and then turns it on (or tells you how).
|
|
560
|
+
|
|
561
|
+
Like the rest of dateblock, it needs a 64-bit `time_t`: every 64-bit
|
|
562
|
+
system has one, and so does current 32-bit ARM Linux. Older 32-bit systems
|
|
563
|
+
can't hold dates past 2038, so the build stops there with an error (see
|
|
564
|
+
[INSTALL.md](https://github.com/caronc/dateblock/blob/master/INSTALL.md)).
|
|
565
|
+
|
|
566
|
+
### From npm (the Node.js package)
|
|
567
|
+
```bash
|
|
568
|
+
npm install @caronc/dateblock
|
|
569
|
+
```
|
|
570
|
+
It comes ready built for Linux (x64 and arm64, including Alpine), macOS
|
|
571
|
+
(Intel and Apple silicon) and Windows (x64 and arm64): npm installs the
|
|
572
|
+
one for your computer, so nothing is compiled and there is no install step
|
|
573
|
+
to approve. Anywhere else, build it once after installing (this needs a
|
|
574
|
+
C++ compiler and Python; see
|
|
575
|
+
[node-gyp](https://github.com/nodejs/node-gyp#installation)); the error
|
|
576
|
+
you get without it says so too:
|
|
577
|
+
```bash
|
|
578
|
+
npm explore @caronc/dateblock -- npm run build
|
|
579
|
+
```
|
|
580
|
+
It needs a 64-bit `time_t` too, so it won't build on older 32-bit systems
|
|
581
|
+
(see [INSTALL.md](https://github.com/caronc/dateblock/blob/master/INSTALL.md)).
|
|
582
|
+
|
|
367
583
|
### From Source
|
|
368
584
|
Assuming you have a C++ compiler and the standard development tools that
|
|
369
585
|
usually go with it (make, autoconf, automake and libtool), then the
|
|
@@ -389,6 +605,20 @@ straight into the Python module):
|
|
|
389
605
|
pip install .
|
|
390
606
|
```
|
|
391
607
|
|
|
608
|
+
To build the PHP extension from your checkout (it needs the PHP development
|
|
609
|
+
files; the C++ code is compiled straight into it unless you add
|
|
610
|
+
`--with-libdateblock` to use the installed library instead):
|
|
611
|
+
```bash
|
|
612
|
+
cd php
|
|
613
|
+
phpize
|
|
614
|
+
./configure
|
|
615
|
+
make
|
|
616
|
+
make test
|
|
617
|
+
sudo make install
|
|
618
|
+
```
|
|
619
|
+
Then turn it on by adding `extension=dateblock` to your `php.ini` (or a new
|
|
620
|
+
file in its `conf.d/` directory).
|
|
621
|
+
|
|
392
622
|
### Building with Docker
|
|
393
623
|
Don't want to install the build tools? If you have
|
|
394
624
|
[Docker](https://www.docker.com/) (or [Podman](https://podman.io/)) and
|