simlock
병렬 코딩 에이전트가 동일 시뮬레이터를 놓고 충돌하지 않도록 제어 평면 제공
개인 계정의 공개 저장소 소유자는 GitHub로 로그인해 운영자를 확인하고 소개를 직접 관리할 수 있습니다. 관리자 승인은 필요하지 않습니다.
로그인한 뒤 확인 파일을 만들어 이 저장소의 기본 브랜치에 30분 안에 커밋해 주세요. 다른 브랜치나 포크의 파일은 인정하지 않습니다. 파일을 올린 뒤 아래에서 확인하면 관리자 승인 없이 관리할 수 있습니다. 자격을 유지하려면 파일을 남겨 두세요.
로그인이 필요하면 로그인 화면으로 이동합니다. 로그인 후 이곳으로 돌아와 원하는 확인 버튼을 다시 눌러 주세요.
프로젝트 폴더에서 /nomorevibe verify를 실행하면 소유권을 확인하고 소개를 직접 관리할 수 있습니다.
1분 만에 확인하기:clock8: :hourglass: timeago.js is a tiny(2.0 kb) library used to format date with `*** time ago` statement.
저장소 README에서 가져옴
README 전체를 불러오는 중입니다.
README 전문 보기 ↗timeago.js is a nano library(less than
2 kb) used to format datetime with*** time agostatement. eg: '3 hours ago'.
ago and time in supported.Official website. React version here: timeago-react. Python version here: timeago.
Such as
just now
12 seconds ago
2 hours ago
3 days ago
3 weeks ago
2 years ago
in 12 seconds
in 3 minutes
in 24 days
in 6 months
npm install timeago.js
import { format, render, cancel, register } from 'timeago.js';
or import with script tag in html file and access global variable timeago.
<script src="dist/timeago.min.js"></script>
// format the time with locale
format('2016-06-12', 'en_US');
Alternatively to NPM, you can also use a CDN which will reflect the latest version as soon as it is published to npm.
<script src="//unpkg.com/timeago.js"></script>
There only 4 API below.
format(date[, locale = 'en_US', opts]), format a Date instance / timestamp / date string to string.
import { format } from 'timeago.js';
// format timestamp
format(1544666010224);
// format date instance
format(new Date(1544666010224));
// format date string
format('2018-12-12');
// format with locale
format(1544666010224, 'zh_CN');
// format with locale and relative date
format(1544666010224, 'zh_CN', { relativeDate: '2018-11-11' });
// e.g.
format(Date.now() - 11 * 1000 * 60 * 60); // returns '11 hours ago'
The default locale is en_US, and the library contains en_US and zh_CN build-in.
render(dom[, locale = 'en_US', opts])
cancel([dom])
Make a dom with
datetimeattribute automatic rendering and cancel.
HTML code:
<div class="timeago" datetime="2016-06-30 09:20:00"></div>
Javascript code:
import { render, cancel } from 'timeago.js';
const nodes = document.querySelectorAll('.timeago');
// use render method to render nodes in real time
render(nodes, 'zh_CN');
// render with opts
// render(nodes, 'en_US', { minInterval: 3 });
// cancel all real-time render task
cancel();
// or cancel for the specific one
cancel(nodes[0])
The 3rd parameter opts contains:
export type Opts = {
/** the relative date */
readonly relativeDate?: TDate;
/** the realtime min update interval */
readonly minInterval?: number;
};
The DOM object should have the attribute
datetimewith date formatted string.
register(locale, localeFunc), register a new locale, build-in locale contains:en_US,zh_CN, all locales here.
You can register your own language with register API.
const localeFunc = (number: number, index: number, totalSec: number): [string, string] => {
// number: the timeago / timein number;
// index: the index of array below;
// totalSec: total seconds between date to be formatted and today's date;
return [
['just now', 'right now'],
['%s seconds ago', 'in %s seconds'],
['1 minute ago', 'in 1 minute'],
['%s minutes ago', 'in %s minutes'],
['1 hour ago', 'in 1 hour'],
['%s hours ago', 'in %s hours'],
['1 day ago', 'in 1 day'],
['%s days ago', 'in %s days'],
['1 week ago', 'in 1 week'],
['%s weeks ago', 'in %s weeks'],
['1 month ago', 'in 1 month'],
['%s months ago', 'in %s months'],
['1 year ago', 'in 1 year'],
['%s years ago', 'in %s years']
][index];
};
// register your locale with timeago
register('my-locale', localeFunc);
// use it
format('2016-06-12', 'my-locale');
npm test. How to write test cases, see locales test cases.MIT@hustcc