Skip to content

Commit

Permalink
UPDATED project
Browse files Browse the repository at this point in the history
  • Loading branch information
FatulM committed Jun 27, 2019
1 parent 801780a commit c055c0b
Show file tree
Hide file tree
Showing 31 changed files with 451 additions and 146 deletions.
70 changes: 64 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,70 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

.DS_Store
.dart_tool/
# Visual Studio Code related
.vscode/

# Flutter/Dart/Pub related
**/doc/api/
.dart_tool/
.flutter-plugins
.packages
.pub-cache/
.pub/

build/
ios/.generated/
ios/Flutter/Generated.xcconfig
ios/Runner/GeneratedPluginRegistrant.*

# Android related
**/android/**/gradle-wrapper.jar
**/android/.gradle
**/android/captures/
**/android/gradlew
**/android/gradlew.bat
**/android/local.properties
**/android/**/GeneratedPluginRegistrant.java

# iOS/XCode related
**/ios/**/*.mode1v3
**/ios/**/*.mode2v3
**/ios/**/*.moved-aside
**/ios/**/*.pbxuser
**/ios/**/*.perspectivev3
**/ios/**/*sync/
**/ios/**/.sconsign.dblite
**/ios/**/.tags*
**/ios/**/.vagrant/
**/ios/**/DerivedData/
**/ios/**/Icon?
**/ios/**/Pods/
**/ios/**/.symlinks/
**/ios/**/profile
**/ios/**/xcuserdata
**/ios/.generated/
**/ios/Flutter/App.framework
**/ios/Flutter/Flutter.framework
**/ios/Flutter/Generated.xcconfig
**/ios/Flutter/app.flx
**/ios/Flutter/app.zip
**/ios/Flutter/flutter_assets/
**/ios/ServiceDefinitions.json
**/ios/Runner/GeneratedPluginRegistrant.*

# Exceptions to above rules.
!**/ios/**/default.mode1v3
!**/ios/**/default.mode2v3
!**/ios/**/default.pbxuser
!**/ios/**/default.perspectivev3
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
2 changes: 1 addition & 1 deletion .metadata
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# This file should be version controlled and should not be manually edited.

version:
revision: 5391447fae6209bb21a89e6a5a6583cac1af9b4b
revision: 7a4c33425ddd78c54aba07d86f3f9a4a0051769b
channel: stable

project_type: package
36 changes: 20 additions & 16 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,65 +1,69 @@
## 0.1
## [0.1]

- Initial version

## 0.2.0
## [0.2.0]

- CHANGED constructor type

## 0.2.1
## [0.2.1]

- CHANGED static methods
- CHANGED monthLength to getter

## 0.3.0
## [0.3.0]

- ADDED fromDate constructor

## 0.3.1
## [0.3.1]

- ADDED toDateTime
- CHANGED fromDate name to fromDateTime
- ADDED now factory

## 0.4.0
## [0.4.0]

- ADDED Date as super interface

## 0.4.1
## [0.4.1]

- ADDED weekDay

## 0.4.2
## [0.4.2]

- ADDED more test cases
- Refactored code and docs

# 0.4.3
# [0.4.3]

- CHANGED internal package structure

# 0.5.0
# [0.5.0]

- ADDED date formatter

# 0.5.1
# [0.5.1]

- ADDED Comparable to Jalali and Gregorian

# 0.5.2
# [0.5.2]

- ADDED comparison operators
- ADDED equals and hashCode

# 0.5.3
# [0.5.3]

- ADDED more tests
- ADDED fromJalali and fromGregorian methods

# 0.5.4
# [0.5.4]

- Better documentation

# 0.5.5
# [0.5.5]

- ADDED copy method
- ADDED copy method

# [0.6.0]

- UPDATED project
File renamed without changes.
18 changes: 12 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,30 @@
# A Flutter package for using Jalali (Shamsi, Solar or Persian) date. You can convert Jalali and Georgian dates to each other.
# A Flutter package for using Jalali (Shamsi, Solar or Persian) date. You can convert and format Jalali and Georgian dates.

[![pub package](https://img.shields.io/pub/v/shamsi_date.svg)](https://pub.dartlang.org/packages/shamsi_date)
![Pub](https://img.shields.io/pub/v/shamsi_date.svg?color=blue)

Converted from the popular Javascript library [jalaali-js](https://github.com/jalaali/jalaali-js).

Calendar conversion is based on the [algorithm provided by Kazimierz M. Borkowski](http://www.astro.uni.torun.pl/~kb/Papers/EMP/PersianC-EMP.htm) and has a very good performance.

## Changes
Added date formatter for custom printing of date objects.
## Key Features
- Convert between [Jalali][], [Gregorian][] and Flutter's [DateTime][] objects.
- Format Jalali and Georgian dates with an easy and powerful syntax using [DateFormatter][].
- Access weekday, julian day number, month length and ...
- Check if you have a valid Jalali date or if the year is a leap year.
- Immutable date object with copy methods for easy manipulation.
- Compare Dates easily with comparison operators or by using [Comparable][].

## Issues and feature request
Please make an issue on Github so I can see your request.
If you want a feature or you found an issue,
please make an issue on Github so I can see your request.

## Usage

Add it to your pubspec.yaml file:

```yaml
dependencies:
shamsi_date: ^0.5.5
shamsi_date: ^0.6.0
```
[Jalali][] class is used for Shamsi (Jalali or Persian) date and [Gregorian][] class is used for Gregorian date.
Expand Down

This file was deleted.

3 changes: 0 additions & 3 deletions android/local.properties

This file was deleted.

3 changes: 1 addition & 2 deletions example/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Miscellaneous
*.class
*.lock
*.log
*.pyc
*.swp
Expand All @@ -26,7 +25,7 @@
.packages
.pub-cache/
.pub/
build/
/build/

# Android related
**/android/**/gradle-wrapper.jar
Expand Down
2 changes: 1 addition & 1 deletion example/.metadata
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# This file should be version controlled and should not be manually edited.

version:
revision: 5391447fae6209bb21a89e6a5a6583cac1af9b4b
revision: 7a4c33425ddd78c54aba07d86f3f9a4a0051769b
channel: stable

project_type: app
115 changes: 84 additions & 31 deletions example/README.md
Original file line number Diff line number Diff line change
@@ -1,44 +1,97 @@
# An Example for shamsi date package
# shamsi_date example

There is a complete example flutter application for shamsi_date package,
which shows today in both Jalali and Georgian.
Clone Github repository if you want to play with it.

Here is a quick start guide for shamsi_date package:

```dart
import 'package:flutter/material.dart';
import 'package:shamsi_date/shamsi_date.dart';
void main() {
runApp(MaterialApp(
title: 'Example for shamsi_date package',
home: MyHomePage(),
));
}
main() {
// Gregorian to Jalali conversion
final g1 = Gregorian(2013, 1, 10);
final j1 = g1.toJalali();
print('$g1 in Gregorian is $j1 in Jalali');
// prints: 2013/1/10 in Gregorian is 1391/10/21 in Jalali
// you can write Jalali.fromGregorian(g1) instead of g1.toJalali()
class MyHomePage extends StatefulWidget {
@override
_MyHomePageState createState() => _MyHomePageState();
}
// Jalali to Gregorian conversion
final j2 = Jalali(1391, 10, 21);
final g2 = j1.toGregorian();
print('$j2 in Jalali is $g2 in Gregorian');
// prints: 1391/10/21 in Jalali is 2013/1/10 in Gregorian
// you can write Gregorian.fromJalali(j1) instead of j1.toGregorian()
// check validity
print('$j1 is valid? ${j1.isValid()}');
// -> true
// check leap year
print('1390 is leap year? ${Jalali(1390).isLeapYear()}');
// -> false
// find month length
print('1390/12 month length? ${Jalali(1390, 12).monthLength}');
// -> 29
// convert DateTime object to Jalali and Gregorian
final dateTime = DateTime.now();
print('now is $dateTime');
print('now is ${Gregorian.fromDateTime(dateTime)} in Gregorian');
print('now is ${Jalali.fromDateTime(dateTime)} in Jalali');
// convert Jalali and Gregorian to DateTime
print('$j1 as DateTime is ${j1.toDateTime()}');
print('$g1 as DateTime is ${g1.toDateTime()}');
class _MyHomePageState extends State<MyHomePage> {
String _format(Date d) {
// now() factory method
print('now is ${Gregorian.now()} in Gregorian');
print('now is ${Jalali.now()} in Jalali');
// find weekDay
print('${j1}.weekDay = ${j1.weekDay}'); // -> 6
print('${g1}.weekDay = ${g1.weekDay}'); // -> 4
// copy method
print('$j1 with year = 1300 is ${j1.copy(year: 1300)}');
// prints: 1391/10/21 with year = 1300 is 1300/10/21
print('$g1 with month = 1 and day = 2 is ${g1.copy(month: 1, day: 2)}');
// prints: 2013/1/10 with month = 1 and day = 2 is 2013/1/2
// formatting examples:
// example one:
String format1(Date d) {
final f = d.formatter;
return '${f.wN} ${f.d} ${f.mN} ${f.yy}';
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Example for shamsi_date package'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(_format(Jalali.now())),
Text(_format(Gregorian.now())),
],
),
),
);
print(format1(j1));
// prints: پنج شنبه 21 دی 91
print(format1(g1));
// prints: Thursday 10 January 13
// example one:
String format2(Date d) {
final f = d.formatter;
return '${f.dd}/${f.mm}/${f.yyyy}';
}
print(format2(j1));
// 21/10/1391
print(format2(g1));
// prints: 10/01/2013
// comparing dates
print(j1 > j2); // -> false
print(j1 <= j2); // -> true
print(g1 >= g2); // -> true
print(g1.compareTo(g2)); // -> 0
print(g1 == g2); // -> true
print(g1 != g1); // -> false
}
```
```
Loading

0 comments on commit c055c0b

Please sign in to comment.