我有一个带有一些时间戳的日志文件
2020-12-03 08:30:00
2020-12-03 08:40:00
...
Run Code Online (Sandbox Code Playgroud)
我从日志提供商的文档中知道时间戳是用 UTC 编写的(尽管不使用 ISO 格式)
现在我想用 date-fns 解析它们:
const toParse = "2020-12-03 08:40:00"
parse(toParse, 'yyyy-MM-dd HH:mm:ss', new Date()).toISOString()
Run Code Online (Sandbox Code Playgroud)
因为我的计算机的区域设置是 UTC+1,所以我看到的是:
> "2020-12-03T07:40:00Z"
Run Code Online (Sandbox Code Playgroud)
预期的:
> "2020-12-03T08:40:00Z".
Run Code Online (Sandbox Code Playgroud)
这是我目前用来告诉 date-fns 解析为 UTC 的技巧:
const toParse = "2020-12-03 08:40:00"
parse(toParse + '+00', 'yyyy-MM-dd HH:mm:ss' + 'X', new Date()).toISOString()
Run Code Online (Sandbox Code Playgroud)
正如预期的那样,
> "2020-12-03T08:40:00Z".
Run Code Online (Sandbox Code Playgroud)
有没有使用 date-fns 执行此操作的正确方法?寻找相当于 moment 的moment.utc()
我遇到了Sails.JS 0.9.8的问题.我想在Model.query()函数中使用promises(我使用sails-mysql adapter).
此代码将起作用:
User.findOne({ email: email })
.then(function(user) {
console.log(user);
});
Run Code Online (Sandbox Code Playgroud)
但这个不会
User.query("SELECT email FROM user WHERE email = ?", [ email ]))
.then(function(err, rows) {
console.log(rows);
})
Run Code Online (Sandbox Code Playgroud)
我对"错误"和"行"都没有定义.
它只是没有实施或我做错了什么?如果没有实现,是否有任何替代使用.query()的promises?
先感谢您
我有一个kubernetes pod陷入"终止"状态,抵制pod删除
NAME READY STATUS RESTARTS AGE
...
funny-turtle-myservice-xxx-yyy 1/1 Terminating 1 11d
...
Run Code Online (Sandbox Code Playgroud)
funny-turtle从那时起删除的helm版本的名称在哪里.
输出:pod "funny-turtle-myservice-xxx-yyy" deleted
结果:它仍然显示在同一状态.- 也尝试过--force --grace-period=0,与额外警告相同的结果
警告:立即删除不等待确认正在运行的资源已终止.资源可能会无限期地继续在集群上运行.
结果: Error from server (NotFound): nodes "ip-xxx.yyy.compute.internal" not found
但它不存在.
所以我假设这个pod以某种方式与aws API"断开连接",从kubectl logs打印的错误消息推断.
我将采取任何建议或指导来解释这里发生的事情以及如何摆脱它.
试图查看"ghost"节点是否仍在那里(kubectl delete node ip-xxx.yyy.compute.internal)但它不存在.
我正在node-pg与打字稿一起使用。
我有一个来自文档的 getPool 实用程序https://node-postgres.com/features/pooling
export const getPool = (config?: PoolConfig) => {
const pool = new Pool(config);
pool.on('error', (err, client) => {
console.error('Unexpected error on idle client', err);
process.exit(-1);
});
return pool;
};
Run Code Online (Sandbox Code Playgroud)
我在异步/等待上下文中像这样使用它
const pool = getPool();
await pool.query('my sql query here...');
Run Code Online (Sandbox Code Playgroud)
当我有一个无效的 SQL 查询时,我会收到此类错误:
error: null value in column "foo" violates not-null constraint
at Parser.parseErrorMessage (node_modules/pg-protocol/src/parser.ts:357:11)
at Parser.handlePacket (node_modules/pg-protocol/src/parser.ts:186:21)
at Parser.parse (node_modules/pg-protocol/src/parser.ts:101:30)
at Socket.<anonymous> (node_modules/pg-protocol/src/index.ts:7:48)
Run Code Online (Sandbox Code Playgroud)
注意:我会理解是否是pool.on('error')s 回调窃取了我的堆栈跟踪,但错误没有以Unexpected error on idle client
请注意,在堆栈跟踪中没有任何行指向我的代码库中的文件。 …
我使用Haxe定位Javascript.
我有一个包(定义为extern)," phaser",包含一个Math类以及许多其他类.我import phaser.*;在我的文件的开头使用,因为我使用了这个包中的许多类,我不想为它们添加前缀phaser..
我想使用Haxe API中的Math类,但是如果我尝试使用它(例如Math.random()),编译器认为我想使用phaser.Math并告诉我其中没有这样的函数.
我可以明确地写出我想要使用Haxe Math类而不是phaser.Math吗?
我试过haxe.Math但没有运气......
提前致谢
我正在尝试编写一个简单的 script-fu 函数。我希望它采用一个filename作为参数并从文件夹(其路径将被硬编码)加载该文件。
基本代码:
(define (myfunction inputfile)
(let * ( (image (cat (file-png-load 1 inputfile inputfile)
^^^^^^^^^
...
Run Code Online (Sandbox Code Playgroud)
这是我想用 ecmascript 语法实现的目标:
"foldername/" + inputfile
Run Code Online (Sandbox Code Playgroud)
我查看了Scheme 文档,但没有看到变量+字符串连接的示例......
https://groups.csail.mit.edu/mac/ftpdir/scheme-7.4/doc-html/scheme_7.html#SEC61
提前致谢,祝您有美好的一天。
javascript ×3
node.js ×2
typescript ×2
api ×1
database ×1
date ×1
date-fns ×1
devops ×1
gimp ×1
haxe ×1
kubernetes ×1
math ×1
postgresql ×1
promise ×1
sails.js ×1
scheme ×1
script-fu ×1
timezone ×1
waterline ×1