Skip to content

Commit

Permalink
Decaffeinate (#157)
Browse files Browse the repository at this point in the history
  • Loading branch information
brunoprietog authored Dec 13, 2024
1 parent 1b5579f commit 30c556d
Show file tree
Hide file tree
Showing 49 changed files with 1,245 additions and 1,070 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ Preset time and date formats that vary with age. The available types are `date`,
**Internationalization (I18n)**
Local Time includes a [set of default `en` translations](lib/assets/javascripts/src/local-time/config/i18n.coffee) which can be updated directly. Or, you can provide an entirely new set in a different locale:
Local Time includes a [set of default `en` translations](lib/assets/javascripts/src/local-time/config/i18n.js) which can be updated directly. Or, you can provide an entirely new set in a different locale:
```js
LocalTime.config.i18n["es"] = {
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/local-time.es2017-esm.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion app/assets/javascripts/local-time.es2017-umd.js

Large diffs are not rendered by default.

39 changes: 0 additions & 39 deletions lib/assets/javascripts/src/local-time/calendar_date.coffee

This file was deleted.

51 changes: 51 additions & 0 deletions lib/assets/javascripts/src/local-time/calendar_date.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import LocalTime from "./local_time"

LocalTime.CalendarDate = class CalendarDate {
static fromDate(date) {
return new (this)(date.getFullYear(), date.getMonth() + 1, date.getDate())
}

static today() {
return this.fromDate(new Date)
}

constructor(year, month, day) {
this.date = new Date(Date.UTC(year, month - 1))
this.date.setUTCDate(day)

this.year = this.date.getUTCFullYear()
this.month = this.date.getUTCMonth() + 1
this.day = this.date.getUTCDate()
this.value = this.date.getTime()
}

equals(calendarDate) {
return calendarDate?.value === this.value
}

is(calendarDate) {
return this.equals(calendarDate)
}

isToday() {
return this.is(this.constructor.today())
}

occursOnSameYearAs(date) {
return this.year === date?.year
}

occursThisYear() {
return this.occursOnSameYearAs(this.constructor.today())
}

daysSince(date) {
if (date) {
return (this.date - date.date) / (1000 * 60 * 60 * 24)
}
}

daysPassed() {
return this.constructor.today().daysSince(this)
}
}
78 changes: 0 additions & 78 deletions lib/assets/javascripts/src/local-time/config/i18n.coffee

This file was deleted.

86 changes: 86 additions & 0 deletions lib/assets/javascripts/src/local-time/config/i18n.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import LocalTime from "../local_time"

LocalTime.config.i18n = {
en: {
date: {
dayNames: [
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday"
],
abbrDayNames: [
"Sun",
"Mon",
"Tue",
"Wed",
"Thu",
"Fri",
"Sat"
],
monthNames: [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
],
abbrMonthNames: [
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"
],
yesterday: "yesterday",
today: "today",
tomorrow: "tomorrow",
on: "on {date}",
formats: {
default: "%b %e, %Y",
thisYear: "%b %e"
}
},
time: {
am: "am",
pm: "pm",
singular: "a {time}",
singularAn: "an {time}",
elapsed: "{time} ago",
second: "second",
seconds: "seconds",
minute: "minute",
minutes: "minutes",
hour: "hour",
hours: "hours",
formats: {
default: "%l:%M%P",
default_24h: "%H:%M"
}
},
datetime: {
at: "{date} at {time}",
formats: {
default: "%B %e, %Y at %l:%M%P %Z",
default_24h: "%B %e, %Y at %H:%M %Z"
}
}
}
}
68 changes: 0 additions & 68 deletions lib/assets/javascripts/src/local-time/controller.coffee

This file was deleted.

Loading

0 comments on commit 30c556d

Please sign in to comment.