Skip to content

Commit

Permalink
Merge pull request #2 from jama5262/setup-all-methods
Browse files Browse the repository at this point in the history
Setup all jiffy methods
  • Loading branch information
jama5262 authored Oct 12, 2019
2 parents c13a7d4 + 6f70330 commit 2e3a134
Show file tree
Hide file tree
Showing 6 changed files with 117 additions and 8 deletions.
8 changes: 8 additions & 0 deletions .idea/libraries/Dart_Packages.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion example/jiffy_example.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import 'package:jiffy/jiffy.dart';

main() async {}
main() async {

print(Jiffy("Changed", "Jama").minute);

}
72 changes: 71 additions & 1 deletion lib/src/jiffy.dart
Original file line number Diff line number Diff line change
@@ -1 +1,71 @@
class Jiffy {}
import 'package:intl/intl.dart';

class Jiffy {
DateTime _dateTime = DateTime.now();

DateTime get dateTime => _dateTime;


Jiffy([String time = "", String pattern = ""]);

Jiffy.unit(num timestamp);

// GET
int get milliseconds => _dateTime.millisecond;
int get seconds => _dateTime.second;
int get minute => _dateTime.minute;
int get hour => _dateTime.hour;
int get date => _dateTime.day;
int get day => _dateTime.weekday;
int get dayOfYear => int.parse(DateFormat("D").format(_dateTime));
int get week => ((dayOfYear - _dateTime.weekday + 10) / 7).floor();
int get month => _dateTime.month;
int get quarter => int.parse(DateFormat("Q").format(_dateTime));
int get year =>_dateTime.year;

// MANIPULATE
String add() {}

String subtract() {}

void startOf() {}

void endOf() {}

String local() {}

String utc() {}

// DISPLAY
String format() {}

String fromNow() {}

String from(Jiffy jiffy) {}

int diff(Jiffy jiffy, [String unit]) {}

int valueOf() {}

int unix() {}

// QUERY
bool isBefore(Jiffy jiffy) {}

bool isAfter(Jiffy jiffy) {}

bool isSame(Jiffy jiffy) {}

bool isSameOrBefore(Jiffy jiffy) {}

bool isSameOrAfter(Jiffy jiffy) {}

bool _isLeapYear() {}

bool get isLeapYear => _isLeapYear();

bool isJiffy(var input) {}

bool isDateTime(var input) {}

}
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ author: Jama Mohamed <[email protected]>
environment:
sdk: '>=2.4.0 <3.0.0'

#dependencies:
# path: ^1.6.0
dependencies:
intl: ^0.16.0

dev_dependencies:
pedantic: ^1.7.0
Expand Down
31 changes: 31 additions & 0 deletions test/jiffy_get_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import 'package:jiffy/jiffy.dart';
import 'package:test/test.dart';

void main() {
group('Test get datetime methods', () {
test("Get seconds", () {
expect(Jiffy().seconds, DateTime.now().second);
});
test("Get seconds", () {
expect(Jiffy().seconds, DateTime.now().second);
});
test("Get minutes", () {
expect(Jiffy().minute, DateTime.now().minute);
});
test("Get hours", () {
expect(Jiffy().hour, DateTime.now().hour);
});
test("Get date", () {
expect(Jiffy().date, DateTime.now().day);
});
test("Get day", () {
expect(Jiffy().day, DateTime.now().weekday);
});
test("Get month", () {
expect(Jiffy().month, DateTime.now().month);
});
test("Get year", () {
expect(Jiffy().year, DateTime.now().year);
});
});
}
4 changes: 0 additions & 4 deletions test/jiffy_test.dart

This file was deleted.

0 comments on commit 2e3a134

Please sign in to comment.