Trên GitHub, basecamp/local_time đã đạt 2.0k sao, ngôn ngữ JavaScript. Rails engine for cache-friendly, client-side local time
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
Local Time makes it easy to display times and dates to users in their local time. Its Rails helpers render <time> elements in UTC (making them cache friendly), and its JavaScript component immediately converts those elements from UTC to the browser's local time.
Installation
Importmaps
Add gem "local_time" to your Gemfile.
Run bundle install
Run bin/importmap pin local-time to add the local-time npm package
To use a strftime format already defined in your app, pass a symbol as the format.
<%= local_time(date, :long) %>
When using the local_time helper I18n.t("time.formats.#{format}"), I18n.t("date.formats.#{format}"), Time::DATE_FORMATS[format], and Date::DATE_FORMATS[format] will be scanned (in that order) for your format.
When using the local_date helper, I18n.t("date.formats.#{format}"), I18n.t("time.formats.#{format}"), Date::DATE_FORMATS[format], and Time::DATE_FORMATS[format] will be scanned (in that order) for your format.
Note: The included strftime JavaScript implementation is not 100% complete. It supports the following directives: %a %A %b %B %c %d %e %H %I %l %m %M %p %P %S %w %y %Y %Z
Time ago helpers
<%= local_time_ago(time) %>
Displays the relative amount of time passed. With age, the descriptions transition from {quantity of seconds, minutes, or hours} to {date + time} to {date}. The <time> elements are updated every 60 seconds.
Examples (in quotes):
Recent: "a second ago", "32 seconds ago", "an hour ago", "14 hours ago"
Yesterday: "yesterday at 5:22pm"
This week: "Tuesday at 12:48am"
This year: "on Nov 17"
Last year: "on Jan 31, 2012"
Relative time helpers
Preset time and date formats that vary with age. The available types are date, time-ago, time-or-date, and weekday. Like the local_time helper, :type can be passed a string or in an options hash.
[!NOTE]
The "default" keys in the i18n configuration object are used for translations in LocalTime's RelativeTime module. They are not used to determine which format is rendered when none is provided. See https://github.com/basecamp/local_time/issues/128 for details.
24-hour time formatting
Local Time supports 24-hour time formats out of the box.
To use this feature, configure the library to favor data-format24 over data-format attributes:
LocalTime.config.useFormat24 = true
The library will now default to using the data-format24 attribute on <time> elements for formatting.
But it will still fall back to data-format if data-format24 is not provided.
The included Rails helpers will automatically look for 24h variants of named formats.
They will search for #{name}_24h in the same places the regular name is looked up.
This is an example of what your app configuration might look like:
basecamp/local_time có 2.0k sao GitHub — tải lại trang để xem số mới nhất, hoặc xem trực tiếp github.com/basecamp/local_time. TopGit phản chiếu số sao của GitHub nhưng không cam kết đến từng phút.
basecamp/local_time có phải mã nguồn mở không?
Có — basecamp/local_time phát hành theo license MIT, nghĩa là mã nguồn mở để đọc, fork và (tùy license) tái sử dụng. Mã: github.com/basecamp/local_time.
basecamp/local_time còn đang phát triển không?
Commit gần nhất trên basecamp/local_time là 2 tháng trước (theo timestamp GitHub). Repo có 125 fork — một chỉ báo về mức độ quan tâm của cộng đồng.
basecamp/local_time là gì?
basecamp/local_time (basecamp/local_time) là dự án JavaScript trên GitHub. Theo mô tả gốc: Rails engine for cache-friendly, client-side local time
Đọc thêm về basecamp/local_time ở đâu?
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/basecamp/local_time là nguồn chính thức.
Đọc đầy đủ README ở tab phía trên.
Chưa chắc local_time có hợp với bạn?
Để ChatGPT, Claude hoặc Perplexity tìm hiểu giúp — bấm bên dưới và xem AI nói gì về local_time.