const LocalizationUtils = brackets.getModule("utils/LocalizationUtils")Converts a language code to its written name, if possible. If not possible, the language code is simply returned.
Kind: global function
Returns: string - The language's name or the given language code
| Param | Type | Description |
|---|---|---|
| locale | string |
The two-char language code |
Formats a given date object into a locale-aware date and time string.
Kind: global function
Returns: string - - The formatted date and time string (e.g., "Dec 24, 2024, 10:30 AM").
| Param | Type | Description |
|---|---|---|
| [date] | Date |
The date object to format. If not provided, the current date and time will be used. |
| [lang] | string |
Optional language code to use for formatting (e.g., 'en', 'fr'). If not provided, defaults to the application locale or 'en'. |
| [dateTimeFormat] | Object |
Optional object specifying the date and time formatting options. Defaults to { dateStyle: 'medium', timeStyle: 'short' }. |
| [dateTimeFormat.dateStyle] | string |
Specifies the date format style. One of: DATE_TIME_STYLE.* |
| [dateTimeFormat.timeStyle] | string |
Specifies the time format style. One of: DATE_TIME_STYLE.* |
Returns a relative time string (e.g., "2 days ago", "in 3 hours") based on the difference between the given date and now.
Kind: global function
Returns: string - - A human-readable relative time string (e.g., "2 days ago", "in 3 hours").
| Param | Type | Description |
|---|---|---|
| [date] | Date |
The date to compare with the current date and time. If not given, defaults to now. |
| [lang] | string |
Optional language code to use for formatting (e.g., 'en', 'fr'). If not provided, defaults to the application locale or 'en'. |
| [fromDate] | Date |
Optional date to use instead of now to compute the relative dateTime from. |
Returns an intelligent date string.
- For dates within the last 30 days or the future: relative time (e.g., "2 days ago", "in 3 hours").
- For dates earlier this year: formatted date (e.g., "Jan 5").
- For dates not in the current year: formatted date with year (e.g., "Jan 5, 2023").
Kind: global function
Returns: string - - An intelligently formatted date string.
| Param | Type | Description |
|---|---|---|
| date | Date |
The date to compare and format. |
| [lang] | string |
Optional language code to use for formatting (e.g., 'en', 'fr'). |