Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1b5a4a5

Browse files
committed
feat: 🎸 add TIME and TIMESTAMP variables
1 parentcf21524 commit1b5a4a5

File tree

4 files changed

+31
-0
lines changed

4 files changed

+31
-0
lines changed

‎lib/createVars.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
constlist=[
22
'MONTH',
33
'YEAR',
4+
'TIME',
5+
'TIMESTAMP',
46
'CI_PLATFORM',
57
'CI_NAME',
68
'GIT_REMOTE',

‎lib/var/TIME.js‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/// Current time in UTC format.
2+
constTIME=()=>(newDate()).toUTCString();
3+
4+
module.exports=TIME;

‎lib/var/TIMESTAMP.js‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/// UNIX timestamp.
2+
constTIMESTAMP=()=>Date.now();
3+
4+
module.exports=TIMESTAMP;

‎test/integration.spec.js‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,4 +249,25 @@ describe('integration', () => {
249249
expect(evar('IS_CI','TRAVIS=yes')).toBe('true');
250250
});
251251
});
252+
253+
describe('TIME',()=>{
254+
test('returns a time string',()=>{
255+
consttime=evar('TIME');
256+
constdate=newDate(time);
257+
258+
expect(typeoftime).toBe('string');
259+
expect(date.getTime()).toBeLessThanOrEqual(Date.now());
260+
expect(date.getTime()).toBeGreaterThanOrEqual(Date.now()-60*60);
261+
});
262+
});
263+
264+
describe('TIMESTAMP',()=>{
265+
test('returns a timestamp number',()=>{
266+
consttime=parseInt(evar('TIMESTAMP'),10);
267+
268+
expect(typeoftime).toBe('number');
269+
expect(time).toBeLessThanOrEqual(Date.now());
270+
expect(time).toBeGreaterThanOrEqual(Date.now()-60*60);
271+
});
272+
});
252273
});

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp