カテゴリー・パッケージ・リポジトリを検索

パッケージ詳細v2.3.0

calendar_time

MomentJS のカレンダータイムの実装、およびその他の多数のヘルパーメソッド。

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
124
いいね数
27
Pub ポイント
130

パッケージをインストール

flutter pub add calendar_time

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

MomentJS のカレンダータイムフォーマットを実装した Flutter/Dart パッケージで、'2時間後'や'2日前'といった直感的な相対時間表示を提供します。日付の操作やフォーマットに役立つ追加のヘルパー関数も含まれており、ユーザー向けアプリケーションでのタイムスタンプ処理を容易にします。クロスプラットフォーム対応で、Android、iOS、Web、macOS、Windows、Linux をサポートしています。このパッケージは、人間が読みやすい形式で時間差を提示するのを簡素化し、動的な時間表示が必要なアプリケーションにおけるUXを向上させます。

用途

  • チャットアプリで相対的なタイムスタンプを表示する
  • ソーシャルフィードでの投稿やアクティビティの年齢表示
  • 通知での時間差のフォーマット
  • 読み取り可能な時間ラベルによるユーザーエクスペリエンスの向上
  • タスク管理アプリにおける日付ロジックの簡素化

主な機能

  • MomentJS風のカレンダータイムフォーマット
  • クロスプラットフォーム互換性
  • 日付操作用のヘルパーメソッド
  • 読みやすい時間表現
  • pub add コマンドによる簡単な統合

適している対象

  • 相対時間表示が必要なアプリ
  • MomentJS に精通した開発者
  • 一貫した時刻フォーマットが必要なプロジェクト
  • リアルタイム更新を伴うUI中心のアプリケーション
  • 開発者の生産性を最優先とするチーム

注意事項

  • 相対的な時間の概念を理解する必要があります
  • 英語以外のロケール用にローカリゼーションのセットアップが必要になる可能性があります
  • 時刻のフォーマットに限定—完全な日付の解析は不可
  • Dart のコア DateTime クラスに依存しています
  • 複雑な日付演算には適していません

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

calendar_time

Implementation of MomentJS's calendarTime function and some other helpful utilities.

I expect this project will get replaced with another more ambitious project in the future, but this has come in very handy. Extensions and pull requests welcome.

Usage

toHuman

Converting a DateTime to a human readable string

import 'package:calendar_time/calendar_time.dart';

main(){
  CalendarTime(DateTime.now()).toHuman; //Today at {current time}
}

Example output:

  • Today at {current time}
  • Tomorrow at {time}
  • Yesterday at {time}
  • {day} at {time}
  • Last {day} at {time}
  • date time (outside of the last or upcoming few weeks)

Honestly just check the code, but it is in line with Moment's logic.

You can also call .toHumanMultiLine that splits the output around at to have date and time on different lines.

format

Formats to current timezone

import 'package:calendar_time/calendar_time.dart';

main(){
  CalendarTime(DateTime.now()).format("yyyy-MM-dd HH:mm");
}

See https://pub.dev/documentation/intl/latest/intl/DateFormat-class.html for options.

isToday

Return if the supplied DateTime is today

import 'package:calendar_time/calendar_time.dart';

main(){
  final calendarTime = CalendarTime(DateTime.now());
  calendarTime.isToday; //true
}
isTomorrow

Return if the supplied DateTime is tomorrow

import 'package:calendar_time/calendar_time.dart';

main(){
  final calendarTime = CalendarTime(DateTime.now());
  calendarTime.isTomorrow; //false
}
isNextWeek

Return if the supplied DateTime is next week

import 'package:calendar_time/calendar_time.dart';

main(){
  final calendarTime = CalendarTime(DateTime.now());
  calendarTime.isNextWeek; //false
}
isYesterday

Return if the supplied DateTime is yesterday

import 'package:calendar_time/calendar_time.dart';

main(){
  final calendarTime = CalendarTime(DateTime.now());
  calendarTime.isYesterday; //false
}
isLastweek

Return if the supplied DateTime is last week

import 'package:calendar_time/calendar_time.dart';

main(){
  final calendarTime = CalendarTime(DateTime.now());
  calendarTime.isLastWeek; //false
}
startOfToday

Return the beginning of today - not to be confused with startOfDay

import 'package:calendar_time/calendar_time.dart';

main(){
  final calendarTime = CalendarTime(DateTime.now());
  calendarTime.startOfToday; // DateTime
}
startOfDay

Return the beginning of the day of the CalendarTime obejct.

import 'package:calendar_time/calendar_time.dart';

main(){
  final calendarTime = CalendarTime(DateTime(2020,1,1));
  calendarTime.startOfDay; // 2020/01/01 0:0:0am
}
startOfYesterday

Return the beginning of yesterday

import 'package:calendar_time/calendar_time.dart';

main(){
  final calendarTime = CalendarTime(DateTime.now());
  calendarTime.startOfYesterday; // DateTime start of yesterday
}
startOfLastWeek

Return the beginning of lastWeek

import 'package:calendar_time/calendar_time.dart';

main(){
  final calendarTime = CalendarTime(DateTime.now());
  calendarTime.startOfLastWeek; // DateTime start of yesterday
}
endOfToday

Return the end of today (23:59:59:999:999) - not to be confused with endOfDay

import 'package:calendar_time/calendar_time.dart';

main(){
  final calendarTime = CalendarTime(DateTime.now());
  calendarTime.endOfToday; // DateTime
}
endOfDay

Return the end of the day of the CalendarTime object (23:59:59:999:999)

import 'package:calendar_time/calendar_time.dart';

main(){
  final calendarTime = CalendarTime(DateTime(2020, 1,1));
  calendarTime.endOfToday; // 2020/01/01 23:59:59:999:999
}
endOfTomorrow

Return the end of tomorrow

import 'package:calendar_time/calendar_time.dart';

main(){
  final calendarTime = CalendarTime(DateTime.now());
  calendarTime.endOfTomorrow; // DateTime
}
endOfNextWeek

Return the end of next week

import 'package:calendar_time/calendar_time.dart';

main(){
  final calendarTime = CalendarTime(DateTime.now());
  calendarTime.endOfNextWeek; // DateTime
}

カテゴリー

依存関係

依存関係一覧 1 件

ソースリポジトリ

このパッケージを使用しているプロジェクト

データはまだありません。