include env fix, decode-universal-time added
This commit is contained in:
parent
3ca189a78c
commit
0260c74e7f
|
|
@ -66,7 +66,6 @@ utils/local_install.sh
|
|||
|
||||
|
||||
### KNOWNN BUGS
|
||||
- in (include "file.lsp") are not available stdlib.lsp finctions like (string-trim ..) etc
|
||||
- (read-url "https://api.nasdaq.com/api/calendar/dividends/") ; hangs in sslclient.cpp line 132
|
||||
|
||||
### TODO
|
||||
|
|
@ -96,8 +95,6 @@ utils/local_install.sh
|
|||
- string functions
|
||||
- compare - needed for sorting, cmp ignore case
|
||||
- regexp match, regexp tokens
|
||||
- date support
|
||||
- decode-universal-time (http://www.lispworks.com/documentation/HyperSpec/Body/f_dec_un.htm)
|
||||
- env functions
|
||||
- get-env, set-env; set-env cannot be implemented in stdlib.lsp, because popen is in fact subshell
|
||||
- macros and then loop, let etc
|
||||
|
|
|
|||
6
ml.cpp
6
ml.cpp
|
|
@ -1393,16 +1393,12 @@ MlValue tcp_client(std::vector<MlValue> args, MlEnvironment &env) {
|
|||
|
||||
// Read a file and execute its code
|
||||
MlValue include(std::vector<MlValue> args, MlEnvironment &env) {
|
||||
// Import is technically not a special form, it's more of a macro.
|
||||
// We can evaluate our arguments.
|
||||
eval_args(args, env);
|
||||
|
||||
if (args.size() != 1)
|
||||
throw MlError(MlValue("include", include), env, args.size() > 1 ? TOO_MANY_ARGS : TOO_FEW_ARGS);
|
||||
|
||||
MlEnvironment e;
|
||||
MlValue result = run(read_file_contents(args[0].as_string()), e);
|
||||
env.combine(e);
|
||||
MlValue result = run(read_file_contents(args[0].as_string()), env);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -180,7 +180,7 @@
|
|||
(defn end-of-prev-month (datetime) (date-add (end-of-month datetime) -1 "month"))
|
||||
(defn start-of-year (datetime) (str-to-date (+ (date-to-str datetime "%Y") "-01-01 00:00:00") "%Y-%m-%d %H:%M:%S"))
|
||||
(defn end-of-year (datetime) (str-to-date (+ (date-to-str datetime "%Y") "-12-31 23:59:59") "%Y-%m-%d %H:%M:%S"))
|
||||
|
||||
(defn decode-universal-time (time) (map (lambda (x) (int x)) (string-split (date-to-str time "%S %M %H %d %m %Y %w") "\s+")))
|
||||
|
||||
; from list of lists creates csv string
|
||||
; (print (make-csv '(("r1c1" "r1c2") ("r2c1" "r2c2"))))
|
||||
|
|
|
|||
|
|
@ -136,6 +136,7 @@
|
|||
(ut::define-test "result of (end-of-prev-month)" '(ut::assert-equal 1619827199 (end-of-prev-month (str-to-date "2021-05-13 10:32:12" "%Y-%m-%d %H:%M:%S"))))
|
||||
(ut::define-test "result of (start-of-year)" '(ut::assert-equal 1609459200 (start-of-year (str-to-date "2021-05-13 10:32:12" "%Y-%m-%d %H:%M:%S"))))
|
||||
(ut::define-test "result of (end-of-year)" '(ut::assert-equal 1640995199 (end-of-year (str-to-date "2021-05-13 10:32:12" "%Y-%m-%d %H:%M:%S"))))
|
||||
(ut::define-test "result of (decode-universal-time 0)" '(ut::assert-equal '(0 0 0 1 1 1970 4) (decode-universal-time 0)))
|
||||
|
||||
(ut::define-test "result of (read-file-lines \"/tmp/f.txt\" counter)" '(ut::assert-equal 3 (read-file-lines "/tmp/f.txt" counter)))
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue