shamsi_date icon indicating copy to clipboard operation
shamsi_date copied to clipboard

The problem of 2124/03/20

Open eshahrvand opened this issue 2 years ago • 5 comments

Problem: The Gregorian date 2124/03/20 must be 1503/01/01 in the Jalali calendar but this lib returns 1502/12/30.

Checks: The Gregorian date 2025/03/20 must be 1403/12/30 in the Jalali calendar which currently is correct but must be rechecked after fixing the reported problem.

@roozbehp typed in the leap year data from the Iranian calendar authority and put it at: https://github.com/roozbehp/persiancalendar/blob/main/kabise.txt

It would be great if automatic tests could be added based on that data to this project.

eshahrvand avatar Apr 14 '24 07:04 eshahrvand

Hi, I've checked this:

final g = Gregorian(2124, 3, 20);
final j = g.toJalali();
print('$g == $j');

this will print:

Gregorian(2124, 3, 20, 0, 0, 0, 0) == Jalali(1502, 12, 30, 0, 0, 0, 0)

FatulM avatar Apr 21 '24 10:04 FatulM

if you check time.ir site date conversion, it says that it is correct.

FatulM avatar Apr 21 '24 10:04 FatulM

time.ir has some issues for this date: please, check the leap year rule and the the test set that Roozbeh provided.

eshahrvand avatar Apr 30 '24 13:04 eshahrvand

the last line included in the file that you mentioned is

1498* 2119-03-21

so no info about 2124.

FatulM avatar May 03 '24 07:05 FatulM

with this simple code:

import 'package:shamsi_date/shamsi_date.dart';

void main() {
  for (int jy = 1206; jy <= 1498; jy++) {
    var j = Jalali(jy);
    var jf = j.formatter;
    var g = j.toGregorian();
    var gf = g.formatter;

    var s = StringBuffer();
    s.write(jf.yyyy);
    if (j.isLeapYear()) {
      s.write("*");
    }
    s.write(" ${gf.yyyy}-${gf.mm}-${gf.dd}");

    print(s);
  }
}

if you compare the output and the file provided by Roozbeh, you can see that (aprt from ** s in the file, which i will output * s in place of them), the contents are equal.

FatulM avatar May 03 '24 07:05 FatulM

Ok, thank you for checking the issue. We can close it but, it would be great if some tests could be added based on that data to the project.

eshahrvand avatar Jun 23 '24 13:06 eshahrvand

Thanks, OK, I will add the tests ...

FatulM avatar Jun 30 '24 10:06 FatulM

I've added the tests, please take a look:

Iranian Calendar Authority Test Cases

it is named: Iranian Calendar Authority Test Cases

FatulM avatar Jun 30 '24 10:06 FatulM

I will close the issue, But if you think the tests are not sufficient or you found official information for the years out of the range tested by the test case, please reopen the issue.

many thanks for supplying the test cases :smile:

FatulM avatar Jun 30 '24 10:06 FatulM