搜尋套件、儲存庫與 APP 分類

套件詳情v6.4.5

jiffy

Jiffy 是一個用於解析、操作、查詢和格式化日期時間的 Flutter(Android、IOS 和 Web)日期時間套件

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
40.6萬
喜歡數
1150
Pub 分數
150

安裝套件

flutter pub add jiffy

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

Jiffy 是一個全面的 Flutter 套件,可用於在多個平台(包括 Android、iOS、Web、macOS、Windows 和 Linux)上處理日期和時間操作。它透過直覺的 API 簡化了日期的解析、操作、查詢和格式化。專為尋求輕量級但功能強大的解決方案的開發者設計,Jiffy 支援國際化,並提供流暢的語法,便於在 Flutter 應用中輕鬆處理日期。

適用情境

  • 解析 ISO 和自定日期字串
  • 格式化日期以供顯示
  • 操作日期(添加/減去天數、月份)
  • 計算時間差
  • 國際化日期格式化
  • 處理時區轉換

主要特色

  • 流暢且易讀的 API
  • 支援多個平台
  • 內建國際化
  • 輕鬆的日期運算
  • 豐富的格式化選項
  • 時間區域感知作業

適合對象

  • Flutter 應用需要強大的日期處理
  • 想要簡潔日期語法的開發者
  • 需要本地化日期的項目
  • 跨平台日期/時間功能
  • 具有複雜日期邏輯的應用程式

使用建議

  • 對於簡單的日期需求,可能有開銷
  • 需要了解區域設定
  • 受限於 Dart 的 DateTime 在底層
  • 不適合高頻率日期計算
  • 文件對於進階功能的說明可能需要更詳細

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

Jiffy

Continuous Integration codecov License: MIT Pub Version Platform

Jiffy is a Flutter (Android, IOS and Web) date time package for parsing, manipulating, querying and formatting dates and time

Full Documentation | API Reference | Installation | ChangeLog | Examples
Discussions

Usage

Format Dates

Jiffy.parse('2021/01/19').format(pattern: 'MMMM do yyyy, h:mm:ss a'); // January 19th 2021, 12:00:00 AM
Jiffy.now().format(pattern: 'EEEE'); // Tuesday
Jiffy.now().format(pattern: 'MMM do yy'); // Mar 2nd 21
Jiffy.now().format(pattern: 'yyyy [escaped] yyyy'); // 2021 escaped 2021
Jiffy.now().format(); // 2021-03-02T15:18:29.922343

Jiffy.parseFromList([2020, 10, 19]).yMMMMd; // January 19, 2021

Jiffy.parseFromMap({
  Unit.year: 2020,
  Unit.month: 10,
  Unit.day: 19,
  Unit.hour: 19
}).dMMMMEEEEyjm; // Monday, October 19, 2020 7:14 PM

//  You can also use pre-set formats
Jiffy.parse('19, Jan 2021', pattern: 'dd, MMM yyyy').yMMMMd; // January 19, 2021
Jiffy.now().yMMMMEEEEdjm; // Tuesday, March 2, 2021 3:20 PM

Relative Time

// From X
Jiffy.parse('1997/09/23').from(Jiffy.parse('2002/10/26')); // 5 years ago
// From Now
Jiffy.parse('1997/09/23').fromNow(); // 25 years ago

// To X
Jiffy.parse('1997/09/23').to(Jiffy.parse('2002/10/26')); // in 5 years
// To Now
Jiffy.parse('1997/09/23').toNow(); // in 25 years

Manipulation

var jiffy = Jiffy.now().add(days: 1);
jiffy.yMMMMd; // March 3, 2021

Jiffy.now().subtract(days: 1).yMMMMd; // March 2, 2021

Jiffy.now()
  .add(hours: 3, days: 1)
  .subtract(minutes: 30, months: 1)
  .yMMMMEEEEdjm; // Wednesday, February 3, 2021 6:07 PM

Jiffy.parse('1997/09/23')
    .startOf(Unit.year)
    .yMMMMEEEEd; // Wednesday, January 1, 1997

Jiffy.parse('1997/09/23')
    .endOf(Unit.month)
    .yMMMMEEEEd; // Tuesday, September 30, 1997

Querying

Jiffy.parse('1997/9/23').isBefore(Jiffy.parse('1997/9/24')); // true

Jiffy.parse('1997/9/23').isAfter(Jiffy.parse('1997/9/20')); // true

Jiffy.parse('1997/9/23').isSame(Jiffy.parse('1997/9/23')); // true

Jiffy.parse('1997/9/23')
  .isBetween(Jiffy.parse('1997/9/20'), Jiffy.parse('1997/9/24')); // true

Locale Support

// Get current locale code, by default it is en_us
Jiffy.now().localeCode; // en_US

// Setting your preferred locale
await Jiffy.setLocale('fr_ca');
Jiffy.now().yMMMMEEEEdjm; // dimanche 26 février 2023 12 h 03

await Jiffy.setLocale('ja');
Jiffy.now().yMMMMEEEEdjm; // 2023年2月26日日曜日 12:02

await Jiffy.setLocale('zh_cn');
Jiffy.now().yMMMMEEEEdjm; // 2023年2月26日星期日 下午12:03

Contributing

For contribution guidelines, see CONTRIBUTING.

Support

Reach out to me at one of the following places!

  • Email me at [jama3137@gmail.com](mailto:jama3137@gmail.com)
  • LinkedIn Jama Mohamed

License

MIT License

Copyright (c) 2019 Jama Mohamed

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

所屬分類

依賴

依賴清單 2 項

原始碼儲存庫

使用此套件的專案

所在榜單