?
avatar farhadst
farhadst
17 Jul 2017

Steps to reproduce the issue

entering dates manually in persian calendar

Expected result

We expect the entering manually date to be saved correctly like set by calendar popup

Actual result

but after save it, in some months, one day will be added or one day will be reduced in set time
#16922(comment)

System information (as much as possible)

joomla 3.7.3

Additional comments

avatar farhadst farhadst - open - 17 Jul 2017
avatar joomla-cms-bot joomla-cms-bot - change - 17 Jul 2017
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 17 Jul 2017
avatar infograf768
infograf768 - comment - 17 Jul 2017

@dgt41
Let's try again. Why would it work fine when using the popup and not when entering manually?

avatar franz-wohlkoenig franz-wohlkoenig - change - 19 Jul 2017
Category Administration
avatar franz-wohlkoenig franz-wohlkoenig - change - 19 Jul 2017
Status New Information Required
avatar brianteeman
brianteeman - comment - 19 Jul 2017

This is not an issue with the persian calendar - it is an issue with the entire calendar - see #17171

avatar infograf768
infograf768 - comment - 22 Jul 2017

It may be specific to Jalali as the issue concerns the correct persian date.
@farhadst
Please test.
#17183

avatar infograf768
infograf768 - comment - 22 Jul 2017

My test with #17183 looks like it does not solve the jalali issue. Not using the popup but directly editing the field may add a number of days depending on the month.

avatar dgt41
dgt41 - comment - 22 Jul 2017

@infograf768 ok I am doing something stupid there, I try to parse the date but the date is not an object but rather a simple array of numbers :(

This should fix the Jalali calendar (around line 1014

							// We need to transform the date for the data-alt-value
							var mdate = new Date(), ndate, date = Date.parseFieldDate(calObj.inputField.value, calObj.params.dateFormat, calObj.params.dateType);
							ndate = Date.localCalToGregorian(date.getFullYear(), date.getMonth(), date.getDate());
							mdate.setFullYear(ndate[0]);
							mdate.setDate(ndate[2]);
							mdate.setMonth(ndate[1]);
							calObj.inputField.setAttribute('data-alt-value', mdate.print(calObj.params.dateFormat, 'gregorian', false));

Let me know if this solves the problem

avatar infograf768
infograf768 - comment - 24 Jul 2017

@dgt41
It does!.

Therefore combining #17183 and your proposal would solve the issue for me.

avatar farhadst
farhadst - comment - 24 Jul 2017

@infograf768 @dgt41
sorry but this change code in media/system/js/fields/calendar.js Has no effect on the problem (manually set persian date)

avatar dgt41
dgt41 - comment - 24 Jul 2017

@farhadst strange, did you also applied #17183?

PS. I think there is a small bug in the above snippet, there shouldn't be a new mdate variable, as that will reset the time to now, this should be the correct one:

// We need to transform the date for the data-alt-value
							var ndate, date = Date.parseFieldDate(calObj.inputField.value, calObj.params.dateFormat, calObj.params.dateType);
							ndate = Date.localCalToGregorian(date.getFullYear(), date.getMonth(), date.getDate());
							date.setFullYear(ndate[0]);
							date.setDate(ndate[2]);
							date.setMonth(ndate[1]);
							calObj.inputField.setAttribute('data-alt-value', date.print(calObj.params.dateFormat, 'gregorian', false));

But again this also requires #17183

avatar infograf768
infograf768 - comment - 24 Jul 2017

@farhadst
When patching calendar.js, please do not forget to set DEBUG on.

avatar farhadst
farhadst - comment - 24 Jul 2017

@infograf768 yes debug is on
@dgt41 in media/system/js/fields/calendar.js line 1013 to 1026 is:

if (calObj.params.dateType !== 'gregorian') {
							// We need to transform the date for the data-alt-value
							var ndate, date = Date.parseFieldDate(calObj.inputField.value, calObj.params.dateFormat, calObj.params.dateType);
							ndate = Date.localCalToGregorian(date.getFullYear(), date.getMonth(), date.getDate());
							date.setFullYear(ndate[0]);
							date.setDate(ndate[2]);
							date.setMonth(ndate[1]);
							calObj.inputField.setAttribute('data-alt-value', date.print(calObj.params.dateFormat, 'gregorian', false));
						} else {
									calObj.inputField.setAttribute('data-local-value', Date.parseFieldDate(calObj.inputField.value, calObj.params.dateFormat, calObj.params.dateType)
									.print(calObj.params.dateFormat, 'gregorian', false));
									calObj.inputField.setAttribute('data-alt-value', Date.parseFieldDate(calObj.inputField.value, calObj.params.dateFormat, calObj.params.dateType)
									.print(calObj.params.dateFormat, 'gregorian', false));
						}

but Has no effect on the problem

avatar dgt41
dgt41 - comment - 24 Jul 2017

@farhadst can you please test this code:
(replace the 4th line in the above code)

ndate = Date.localCalToGregorian(date.getLocalFullYear('gregorian'), date.getLocalMonth('gregorian'), date.getLocalDate('gregorian'));
avatar farhadst
farhadst - comment - 25 Jul 2017

@dgt41 i replace code but no effect on the problem

avatar dgt41
dgt41 - comment - 25 Jul 2017

@farhadst can you please provide some dates to test/debug this.
What I need is the

  • typed date (jalali)
  • saved date (jalali)
  • saved date (gregorian, eg from the db)
avatar farhadst
farhadst - comment - 25 Jul 2017

screencapture_17-07-25_16 27 59

first date is: ۱۳۹۶-۰۳-۰۸ ۰۰:۱۱:۰۰ = 1396-03-08 00:11:00 = 2017-05-29
date from 08 change to 09 and save but one day will be reduced and date is 08
no effect typ persian number or latin number

avatar dgt41
dgt41 - comment - 25 Jul 2017

@farhadst excellent, thank you. That will make it way easier to debug. One more thing you mentioned that the date can also be reduced by one day, can you provide the same set of data as before for such a behaviour?

avatar farhadst
farhadst - comment - 25 Jul 2017

@dgt41 i check again and behaviour is the like befor:

If one of the January days is chosen according to Jalali, one day will be added to set date,
for example if set 1396-10-26 (16January) and save it, date change to 1396-10-27

any date In February, 1 day is added to the selected date

any date In March, 2 days from the chosen date will be reduced
for example if set 1396-12-24 (15March) and save it, date change to 1396-12-22

any date In April, no day can be chosen and if set any date, this change to the first of may
any date In may, 1 days from the chosen date will be reduced
There is no problem in June
any date In july, 1 days from the chosen date will be reduced
There is no problem in August and September
any date In October, 1 days from the chosen date will be reduced
any date In November, 1 day is added to the selected date
There is no problem in December

avatar farhadst
farhadst - comment - 25 Jul 2017

An interesting point
if click on date box and then click on popup calendar, date change but if no click on date box and just click on popup calendar date no change

screencapture_17-07-25_17 12 59

avatar infograf768
infograf768 - comment - 6 Aug 2017

@farhadst

Please, look at this and post your comments there (concerns the calendar itself, not the field)

#17389


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/17150.

avatar farhadst
farhadst - comment - 6 Aug 2017

@infograf768 I check this and Yes, this problem was to persian calendar (day name incorrect)
with file replacement problem fixed and now day name is correct

avatar dgt41
dgt41 - comment - 8 Aug 2017

@farhadst this was fixed or there is something still pending here?

avatar farhadst
farhadst - comment - 9 Aug 2017

@dgt41 No this issue not fixed and is still pending

avatar franz-wohlkoenig franz-wohlkoenig - change - 9 Aug 2017
Status Information Required Discussion
avatar dgt41
dgt41 - comment - 9 Aug 2017

@farhadst so which part is still buggy?

avatar farhadst
farhadst - comment - 9 Aug 2017

@dgt41 yes this part is still buggy

avatar brianteeman
brianteeman - comment - 5 Oct 2017

What exactly is not working now?

avatar franz-wohlkoenig franz-wohlkoenig - change - 5 Oct 2017
Status Discussion Information Required
avatar farhadst
farhadst - comment - 5 Oct 2017

@brianteeman I gave a full explanation on this post

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 22 Oct 2017

any Opinion @brianteeman?


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/17150.

avatar brianteeman
brianteeman - comment - 22 Dec 2017

The error described by @farhadst sounds unrelated to the calendar localisation and more to do with a difference in the timezone settings between the site and the server

avatar franz-wohlkoenig franz-wohlkoenig - change - 22 Dec 2017
Status Information Required Closed
Closed_Date 0000-00-00 00:00:00 2017-12-22 15:13:04
Closed_By franz-wohlkoenig
avatar joomla-cms-bot joomla-cms-bot - change - 22 Dec 2017
Closed_By franz-wohlkoenig joomla-cms-bot
avatar joomla-cms-bot joomla-cms-bot - close - 22 Dec 2017
avatar joomla-cms-bot
joomla-cms-bot - comment - 22 Dec 2017
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 22 Dec 2017

closed as stated above. Issue can always reopened.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/17150.

Add a Comment

Login with GitHub to post a comment