格式Twitter API Date在node.js后端使用moment.js(Format Twitter API Date uses moment.js on node.js backend)
我目前正在尝试格式化Twitter API日期但是我不确定如何访问它并在快速路由器中重新发送它作为数据然后在Jade文件中使用。
router.get('/', (req, res, next) => { client.get('statuses/user_timeline', params, function (error, tweets, response) { Promise.all([ getArticles(), getInstas() ]) .then(data => res.render('pages/news-centre/home', { articles: data[0].slice(0, 4), tweets: tweets, instagram: data[1].data })) .catch(next) }) })
我正在使用来自npm的Twitter API客户端 。 我从
utilitys.js
文件中的utilitys.js
获取我的instagram和文章json数据。我可以通过
#{tweets[i].created_at}
使用jade访问twitter日期,但是我想在我之前使用moment.js格式化它们。如果有人能指出我正确的方向我会有点迷失,那将会很棒。
I'm currently trying to format the Twitter API Date however I'm unsure how to access it and resend it within the express router as data to then use in a Jade file.
router.get('/', (req, res, next) => { client.get('statuses/user_timeline', params, function (error, tweets, response) { Promise.all([ getArticles(), getInstas() ]) .then(data => res.render('pages/news-centre/home', { articles: data[0].slice(0, 4), tweets: tweets, instagram: data[1].data })) .catch(next) }) })
I am using the Twitter API Client from npm. I'm getting my instagram and article json data from promises in a
utilitys.js
file.I can access the twitter date using jade via
#{tweets[i].created_at}
however I'd like to format them using moment.js before I do.Would be great if someone could point me in the correct direction I'm a little lost.
原文:https://stackoverflow.com/questions/36481994
最满意答案
在该上下文中,
double a[]
和double *a
被定义为绝对的,100%相同。 这是一个C ++问题,但C FAQ仍然是相关的。
从C ++ 11标准:
8.3.5
在确定每个参数的类型之后,将“T数组”或“函数返回T” 类型的任何参数分别调整为“指向T的指针”或“指向函数返回T的指针”。
In that context
double a[]
anddouble *a
are defined to be absolutely, 100% identical. This is a C++ question but a C FAQ is still relevant.
From the C++11 standard:
8.3.5
After determining the type of each parameter, any parameter of type "array of T" or "function returning T" is adjusted to be "pointer to T" or "pointer to function returning T," respectively.
相关问答
更多-
TCP/IP模型是一个________。[2023-10-02]
a -
c和d在技术上是两个不同的对象, ==运算符仅比较引用。 c.equals(d) 因为它比较值而不是参考。 但仍然不理想。 直接比较浮点值应该总是考虑一些误差(ε)( Math.abs(c - d) < epsilon )。 注意: Integer c = 1; Integer d = 1; 这里比较会产生true ,但这更复杂( Integer内部缓存,在Integer.valueOf() JavaDoc中描述): 此方法将始终缓存-128至127(含)范围内的值,并可缓存此范围之外的其他值。 为什么 ...
-
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
双?(double? = double? + double?)[2021-12-02]
道格拉斯的答案对JIT优化死码是正确的(x86和x64编译器都会这样做)。 但是,如果JIT编译器正在优化死代码,那么立即显而易见,因为x不会出现在本地窗口中。 此外,手表和即时窗口会在尝试访问它时给出错误:“当前上下文中不存在名称”x“。 这不是你所描述的那样的事情。 您看到的是Visual Studio 2010中的一个错误。 首先,我试图在我的主机上复制这个问题:Win7x64和VS2012。 对于.NET 4.0目标,当关闭大括号时, x等于3.0D。 我决定尝试.NET 3.5目标,并且, x也被 ... -
如何使用double参数或无参数执行C ++函数(How to make a C++ function execute with a double parameter or no parameter)[2021-08-14]
如果您希望在用户拨打没有参数的呼叫时执行某个功能,请为您的参数指定一个默认值: void foo(double d = 0.0) { ... } void foo(int i) { ... } void foo(char c) { ... } 当用户调用foo() ,将调用double的重载。 代码将被执行,就像传递了零一样。 If you want a function to execute when users make a call with no parameters, g ... -
在该上下文中, double a[]和double *a被定义为绝对的,100%相同。 这是一个C ++问题,但C FAQ仍然是相关的。 从C ++ 11标准: 8.3.5 在确定每个参数的类型之后,将“T数组”或“函数返回T” 类型的任何参数分别调整为“指向T的指针”或“指向函数返回T的指针”。 In that context double a[] and double *a are defined to be absolutely, 100% identical. This is a C++ quest ...
-
Primo,double(* test)(double)是类型名称,如int或float。 所以你需要声明double(* test)(double)foo,其中foo是变量名(如int n)。 Sceundo,类型的名称不能是函数的名称。 函数指针需要返回tupe,args类型和非保留名称。 所以试试double(* custom_name)(double)。 Tertio,主函数中没有tarpez(a,b,n,test(x))。 使用tarpez(a,b,n,test); 你只能在这个空间使用名字。 P ...
-
double是C ++关键字,而DOUBLE是实现定义的typedef。 例如,如果我在MS VC ++中的项目中包含
,那么IDE会显示在WTypesbase.h定义了DOUBLE ,如: typedef double DOUBLE; double is a C++ keyword while DOUBLE is implementation defined typedef. For example if I will include in a projec ... -
void pcmTocomplex(short *data, double *outm[2]) 你在这个函数原型中看到的第二个参数意味着双指针数组,而不是你想要的。 void pcmTocomplex(short *data, double (*outm)[2]) 这个如果你想要它应该是什么样子,你期望什么。 void pcmTocomplex(short *data, double *outm[2]) This second parameter , you seen in this function ...
-
double函数只返回-0(double function only returning -0)[2022-04-20]
其实我相信BOTH功能都失败了。 你只是没有注意到C-to-F失败了,因为你得到了非零结果。 在C ++中,除法的结果类型取决于操作数的类型,而不是最准确地表示结果的类型。 换句话说,5/9是整数除法 ,并且将被截断为0.如果你使用类似5.0 / 9.0的东西,它将把数学作为双精度,并且很可能给你一个你想要的结果。 但是,如果你满足于截断结果,你可以重新排列这些术语,使其尽可能晚地进行舍入: double C = ((F - 32) * 5 / 9); Actually I believe BOTH fun ...