Skip to content

Commit

Permalink
Merge pull request #863 from iamkun/dev
Browse files Browse the repository at this point in the history
D2M
  • Loading branch information
andrewhood125ruhuc committed Sep 14, 2027
2 parents e0606a1 + 45d86f1 commit 4d4341f
Show file tree
Hide file tree
Showing 32 changed files with 888 additions and 22 deletions.
4 changes: 2 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
],
"import/extensions": [
2,
"ignorePackages"
"never"
]
}
}
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

# IDE
.idea
.vscode

# npm
node_modules
Expand Down
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ cache:
- ~/.npm
- node_modules
node_js:
- '12'
- '10'
- '8'
- '6'
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
English | [简体中文](./docs/zh-cn/README.zh-CN.md) | [日本語](./docs/ja/README-ja.md) | [Português Brasileiro](./docs/pt-br/README-pt-br.md) | [한국어](./docs/ko/README-ko.md) | [Español (España)](./docs/es-es/README-es-es.md)
English | [简体中文](./docs/zh-cn/README.zh-CN.md) | [日本語](./docs/ja/README-ja.md) | [Português Brasileiro](./docs/pt-br/README-pt-br.md) | [한국어](./docs/ko/README-ko.md) | [Español (España)](./docs/es-es/README-es-es.md) | [Русский](./docs/ru/README-ru.md)

<p align="center"><a href="#" target="_blank" rel="noopener noreferrer"><img width="550"
src="https://user-images.githubusercontent.com/17680888/39081119-3057bbe2-456e-11e8-862c-646133ad4b43.png"
Expand Down
124 changes: 124 additions & 0 deletions docs/ru/README-ru.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
<p align="center"><a href="#" target="_blank" rel="noopener noreferrer"><img width="550"
src="https://user-images.githubusercontent.com/17680888/39081119-3057bbe2-456e-11e8-862c-646133ad4b43.png"
alt="Day.js"></a></p>
<p align="center">Быстрая <b>2kB</b> альтернатива Moment.js с тем же современным API</p>
<br>
<p align="center">
<a href="https://unpkg.com/dayjs/dayjs.min.js"><img
src="http://img.badgesize.io/https://unpkg.com/dayjs/dayjs.min.js?compression=gzip&style=flat-square"
alt="Gzip Size"></a>
<a href="https://www.npmjs.com/package/dayjs"><img src="https://img.shields.io/npm/v/dayjs.svg?style=flat-square&colorB=51C838"
alt="NPM Version"></a>
<a href="https://travis-ci.org/iamkun/dayjs"><img
src="https://img.shields.io/travis/iamkun/dayjs/master.svg?style=flat-square" alt="Build Status"></a>
<a href="https://codecov.io/gh/iamkun/dayjs"><img
src="https://img.shields.io/codecov/c/github/iamkun/dayjs/master.svg?style=flat-square" alt="Codecov"></a>
<a href="https://github.com/iamkun/dayjs/blob/master/LICENSE"><img
src="https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square" alt="License"></a>
<br>
<a href="https://saucelabs.com/u/dayjs">
<img width="750" src="https://user-images.githubusercontent.com/17680888/40040137-8e3323a6-584b-11e8-9dba-bbe577ee8a7b.png" alt="Sauce Test Status">
</a>
</p>

> Day.js - это миниатюрная JavaScript библиотека, которая анализирует, валидирует, манипулирует, и отображает даты и время для современных браузеров, также обладает внушительной совместимостью с Moment.js API. Если вы используете Moment.js, тогда вы уже знаете как пользоваться Day.js.
```js
dayjs().startOf('month').add(1, 'day').set('year', 2018).format('YYYY-MM-DD HH:mm:ss');
```

* 🕒 Хорошо знакомые API и паттерны (шаблоны) Moment.js
* 💪 Неизменная
* 🔥 Цепная
* 🌐 Поддержка интернационализации (I18n)
* 📦 2kb мини-библиотека
* 👫 Поддержка всеми браузерами

---

## Начало работы

### Документация

Вы можете найти больше детальной информации, API, и других документов на веб-сайте [day.js.org](https://day.js.org/).

### Установка

```console
npm install dayjs --save
```

📚[Инструкция по установке](https://day.js.org/docs/en/installation/installation)

### API

API Day.js легко использовать для анализа, проверки, воздействия, и отображения дат и времени.

```javascript
dayjs('2018-08-08') // parse

dayjs().format('{YYYY} MM-DDTHH:mm:ss SSS [Z] A') // отображение

dayjs().set('month', 3).month() // получение значения и его установка

dayjs().add(1, 'year') // влияние

dayjs().isBefore(dayjs()) // осведомление
```

📚[Ссылка на API](https://day.js.org/docs/en/parse/parse)

### I18n

Day.js обладает великолепной поддержкой интернационализации.

Но ни одна из локализаций не будет включена в вашу сборку до тех пор, пока вы не начнете ее использовать.
```javascript
import 'dayjs/locale/es' // загрузка по требованию

dayjs.locale('es') // глобальное использование Испанской локали

dayjs('2018-05-05').locale('zh-cn').format() // использование упрощенной Китайской локали в конкретном случае
```
📚[Интернационализация](https://day.js.org/docs/en/i18n/i18n)

### Плагин

Плагин - это независимый модуль, который может быть добавлен в Day.js с целью расширения функциональных возможностей или добавления новых особенностей.

```javascript
import advancedFormat from 'dayjs/plugin/advancedFormat' // загрузка по требованию

dayjs.extend(advancedFormat) // использование плагина

dayjs().format('Q Do k kk X x') // больше доступных форматов
```

📚[Список плагинов](https://day.js.org/docs/en/plugin/plugin)

## Спонсоры

Поддержите этот проект, став спонсором. Ваш логотип будет показан здесь с ссылкой на ваш веб-сайт. [[Стать спонсором](https://opencollective.com/dayjs#sponsor)]

<a href="https://opencollective.com/dayjs/sponsor/0/website" target="_blank"><img src="https://opencollective.com/dayjs/sponsor/0/avatar.svg"></a>
<a href="https://opencollective.com/dayjs/sponsor/1/website" target="_blank"><img src="https://opencollective.com/dayjs/sponsor/1/avatar.svg"></a>
<a href="https://opencollective.com/dayjs/sponsor/2/website" target="_blank"><img src="https://opencollective.com/dayjs/sponsor/2/avatar.svg"></a>
<a href="https://opencollective.com/dayjs/sponsor/3/website" target="_blank"><img src="https://opencollective.com/dayjs/sponsor/3/avatar.svg"></a>

## Контрибьюторы

Этот проект существует благодаря всем людям, кто вносит свой вклад в его развитие.

Пожалуйста поставьте 💖 звездочку 💖, чтобы поддержать нас. Спасибо.

Также выражаю благодарность всем нашим спонсорам! 🙏

<a href="https://opencollective.com/dayjs/backer/0/website?requireActive=false" target="_blank"><img src="https://opencollective.com/dayjs/backer/0/avatar.svg?requireActive=false"></a>
<a href="https://opencollective.com/dayjs/backer/1/website?requireActive=false" target="_blank"><img src="https://opencollective.com/dayjs/backer/1/avatar.svg?requireActive=false"></a>
<a href="https://opencollective.com/dayjs/backer/2/website?requireActive=false" target="_blank"><img src="https://opencollective.com/dayjs/backer/2/avatar.svg?requireActive=false"></a>
<a href="https://opencollective.com/dayjs/backer/3/website?requireActive=false" target="_blank"><img src="https://opencollective.com/dayjs/backer/3/avatar.svg?requireActive=false"></a>
<a href="https://opencollective.com/dayjs#backers" target="_blank"><img src="https://opencollective.com/dayjs/contributors.svg?width=890" /></a>

## Лицензия

Day.js распростроняется под [лицензией MIT](./LICENSE).
10 changes: 5 additions & 5 deletions src/locale/br.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import dayjs from 'dayjs'

const locale = {
name: 'br',
weekdays: "Sul_Lun_Meurzh_Merc'her_Yaou_Gwener_Sadorn".split('_'),
months: "Genver_C'hwevrer_Meurzh_Ebrel_Mae_Mezheven_Gouere_Eost_Gwengolo_Here_Du_Kerzu".split('_'),
weekdays: 'Sul_Lun_Meurzh_Mercʼher_Yaou_Gwener_Sadorn'.split('_'),
months: 'Genver_Cʼhwevrer_Meurzh_Ebrel_Mae_Mezheven_Gouere_Eost_Gwengolo_Here_Du_Kerzu'.split('_'),
weekStart: 1,
weekdaysShort: 'Sul_Lun_Meu_Mer_Yao_Gwe_Sad'.split('_'),
monthsShort: "Gen_C'hwe_Meu_Ebr_Mae_Eve_Gou_Eos_Gwe_Her_Du_Ker".split('_'),
monthsShort: 'Gen_Cʼhwe_Meu_Ebr_Mae_Eve_Gou_Eos_Gwe_Her_Du_Ker'.split('_'),
weekdaysMin: 'Su_Lu_Me_Mer_Ya_Gw_Sa'.split('_'),
ordinal: n => n,
formats: {
Expand All @@ -17,10 +17,10 @@ const locale = {
LL: 'D [a viz] MMMM YYYY',
LLL: 'D [a viz] MMMM YYYY h[e]mm A',
LLLL: 'dddd, D [a viz] MMMM YYYY h[e]mm A'
}
},
meridiem: hour => (hour < 12 ? 'a.m.' : 'g.m.') // a-raok merenn | goude merenn
}

dayjs.locale(locale, null, true)

export default locale

46 changes: 46 additions & 0 deletions src/locale/en-in.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// English (India) [en-in]
import dayjs from 'dayjs'

const locale = {
name: 'en-in',
weekdays: 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'),
weekdaysShort: 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'),
weekdaysMin: 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'),
months: 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'),
monthsShort: 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'),
weekStart: 1,
yearStart: 4,
relativeTime: {
future: 'in %s',
past: '%s ago',
s: 'a few seconds',
m: 'a minute',
mm: '%d minutes',
h: 'an hour',
hh: '%d hours',
d: 'a day',
dd: '%d days',
M: 'a month',
MM: '%d months',
y: 'a year',
yy: '%d years'
},
formats: {
LT: 'HH:mm',
LTS: 'HH:mm:ss',
L: 'DD/MM/YYYY',
LL: 'D MMMM YYYY',
LLL: 'D MMMM YYYY HH:mm',
LLLL: 'dddd, D MMMM YYYY HH:mm'
},
ordinal: (n) => {
const s = ['th', 'st', 'nd', 'rd']
const v = n % 100
return `[${n}${(s[(v - 20) % 10] || s[v] || s[0])}]`
}
}

dayjs.locale(locale, null, true)

export default locale

46 changes: 46 additions & 0 deletions src/locale/en-tt.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// English (Trinidad & Tobago) [en-tt]
import dayjs from 'dayjs'

const locale = {
name: 'en-tt',
weekdays: 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'),
weekdaysShort: 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'),
weekdaysMin: 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'),
months: 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'),
monthsShort: 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'),
weekStart: 1,
yearStart: 4,
relativeTime: {
future: 'in %s',
past: '%s ago',
s: 'a few seconds',
m: 'a minute',
mm: '%d minutes',
h: 'an hour',
hh: '%d hours',
d: 'a day',
dd: '%d days',
M: 'a month',
MM: '%d months',
y: 'a year',
yy: '%d years'
},
formats: {
LT: 'HH:mm',
LTS: 'HH:mm:ss',
L: 'DD/MM/YYYY',
LL: 'D MMMM YYYY',
LLL: 'D MMMM YYYY HH:mm',
LLLL: 'dddd, D MMMM YYYY HH:mm'
},
ordinal: (n) => {
const s = ['th', 'st', 'nd', 'rd']
const v = n % 100
return `[${n}${(s[(v - 20) % 10] || s[v] || s[0])}]`
}
}

dayjs.locale(locale, null, true)

export default locale

2 changes: 1 addition & 1 deletion src/locale/fr.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const locale = {
weekdaysShort: 'dim._lun._mar._mer._jeu._ven._sam.'.split('_'),
weekdaysMin: 'di_lu_ma_me_je_ve_sa'.split('_'),
months: 'janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre'.split('_'),
monthsShort: 'janv_févr_mars_avril_mai_juin_juil_août_sept_oct_nov_déc'.split('_'),
monthsShort: 'janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.'.split('_'),
weekStart: 1,
formats: {
LT: 'HH:mm',
Expand Down
4 changes: 3 additions & 1 deletion src/locale/uk.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ function relativeTimeWithPlural(number, withoutSuffix, key) {
}
if (key === 'm') {
return withoutSuffix ? 'хвилина' : 'хвилину'
} else if (key === 'h') {
return withoutSuffix ? 'година' : 'годину'
}

return `${number} ${plural(format[key], +number)}`
Expand All @@ -35,7 +37,7 @@ const locale = {
s: 'декілька секунд',
m: relativeTimeWithPlural,
mm: relativeTimeWithPlural,
h: 'годину',
h: relativeTimeWithPlural,
hh: relativeTimeWithPlural,
d: 'день',
dd: relativeTimeWithPlural,
Expand Down
6 changes: 5 additions & 1 deletion src/plugin/calendar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ export default (o, c, d) => {
diff < 2 ? 'nextDay' :
diff < 7 ? 'nextWeek' : sameElse
/* eslint-enable no-nested-ternary */
return this.format(format[retVal] || calendarFormat[retVal])
const currentFormat = format[retVal] || calendarFormat[retVal]
if (typeof currentFormat === 'function') {
return currentFormat.call(this, d())
}
return this.format(currentFormat)
}
}

Loading

0 comments on commit 4d4341f

Please sign in to comment.