-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from jama5262/setup-all-methods
Setup all jiffy methods
- Loading branch information
Showing
6 changed files
with
117 additions
and
8 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) {} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); | ||
} |
This file was deleted.
Oops, something went wrong.