GithubHelp home page GithubHelp logo

tchigher / jiffy Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jama5262/jiffy

0.0 0.0 0.0 101 KB

Jiffy is a Flutter and dart web date time package inspired by momentjs for parsing, manipulating and formatting dates

Home Page: https://pub.dev/packages/jiffy

License: MIT License

Dart 99.36% Shell 0.64%

jiffy's Introduction

Jiffy

Build Status Coverage Status License: MIT Pub Version Platform

Jiffy is a dart date time package inspired by momentjs for parsing, manipulating, querying and formatting dates

Full Documentation | Installation | ChangeLog | Examples

Usage

Format Dates

Jiffy().format("MMMM dd yyyy, h:mm:ss a"); // October 19 2019, 7:00:53 PM
Jiffy().format("EEEE"); // Saturday
Jiffy("2019-10-2").format("yyyy 'escaped' yyyy"); // 2019 escaped 2019
Jiffy().format(); // 2019-10-19T19:00:53.090646

Jiffy([2019, 10, 19]).yMMMMd; // October 19, 2019
Jiffy({
  "year": 2019,
  "month": 10,
  "day": 19,
  "hour": 19
}).yMMMMEEEEdjm; // Saturday, October 19, 2019 7:00 PM

//  You can also use default formats
Jiffy("19, Oct 2019", "dd, MMM yyyy").yMMMMd; // October 19, 2019
Jiffy().yMMMMEEEEdjm; // Saturday, October 19, 2019 7:00 PM

Relative Time

Jiffy("2011-10-31", "yyyy-MM-dd").fromNow(); // 8 years ago
Jiffy("2012-06-20").fromNow(); // 7 years ago

var jiffy1 = Jiffy()
    ..startOf("day");
jiffy1.fromNow(); // 19 hours ago

var jiffy2 = Jiffy()
    ..endOf("day");
jiffy2.fromNow(); // in 5 hours

var jiffy3 = Jiffy()
    ..startOf("hour");
jiffy3.fromNow(); // 9 minutes ago

Manipulation

var jiffy1 = Jiffy()
    ..add(duration: Duration(days: 1));
jiffy1.yMMMMd; // October 20, 2019

var jiffy2 = Jiffy()
    ..subtract(days: 1);
jiffy2.yMMMMd; // October 18, 2019

//  You can chain methods by using Dart method cascading
var jiffy3 = Jiffy()
    ..add(days: 1)
    ..add(hours: 3)
    ..subtract(minutes: 30);
jiffy3.yMMMMEEEEdjm; // Sunday, October 20, 2019 9:50 PM

var jiffy4 = Jiffy()
    ..add(duration: Duration(days: 1))
    ..add(duration: Duration(hours: 3))
    ..subtract(duration: Duration(minutes: 30));
jiffy4.format("dd/MM/yyy"); // 20/10/2019


// Months and year are added in respect to how many days there are in a months and if is a year is a leap year
Jiffy("2010-1-31", "yyyy-MM-dd"); // This is January 31
Jiffy("2010-1-31", "yyyy-MM-dd").add(months: 1); // This is February 28

Locale Support

//  The locale method always return a future
//  To get locale (The default locale is English)
await Jiffy.locale(); // en

//  To set locale
await Jiffy.locale("fr");
Jiffy().yMMMMEEEEdjm; // samedi 19 octobre 2019 19:25

await Jiffy.locale("ar");
Jiffy().yMMMMEEEEdjm; // السبت، ١٩ أكتوبر ٢٠١٩ ٧:٢٧ م

await Jiffy.locale("zh-cn");
Jiffy().yMMMMEEEEdjm; // 2019年10月19日星期六 下午7:28

Contributing

To contribute, follow the following easy steps

Step 1
  • Fork this repo! or

  • Clone this repo to your local machine using https://github.com/jama5262/jiffy.git

Step 2
  • Make your own updates
Step 3
  • Create a new pull request

Support

Reach out to me at one of the following places!

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.

jiffy's People

Contributors

jama5262 avatar yongjhih avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.