SAY DATETIME says wrong date

I am using the Say DateTime agi function but it says the wrong date
I am sending SAY DATETIME 1629967200 "" "QIMP" "" but it says

Playing ‘digits/today.ulaw’ (language ‘en’)
Playing ‘digits/8.ulaw’ (language ‘en’)
Playing ‘digits/40.ulaw’ (language ‘en’)
Playing ‘digits/a-m.ulaw’ (language ‘en’)

The server time is

Wed Aug 25 18:31:46 UTC 2021

What is wrong?

If you enter:

TZ=UTC date --date=@1629967200

into a shell, you get:

Thu Aug 26 08:40:00 UTC 2021

So Asterisk is converting the ‘epoch’ time value correctly.

Where are you getting the value you supply to DATETIME and why is it different that what you get from:

date +%s

It probably doesn’t like your specifying a date in the future. You didn’t actually say what the time you were specifying was but it is easy to check:

david@dhcppc4:~$ TZ=UTC date --date=@1629967200
Thu 26 Aug 08:40:00 UTC 2021

I think, if I were implementing a Q format that allowed for the future, I would have included “tomorrow” as a special case, which does imply it wasn’t expecting future dates.

Yes. It’s basically doing what I thought. Any time after the start of the current day is treated as being today.

A change to avoid that should be fairly obvious, without much knowledge of C, but really you should add the tomorrow case as well, if you are going to do it, in which case most of the work will be in fixing up the documentation, as it looks like it isn’t limited to that file.

At least it should say the date and not today

Looks like I missed that today is Wednesday. Oops.

@david551 The code needs to be changed to this

if (beg_today + 15768000 < t) {
						/* More than 6 months from now - "April nineteenth two thousand three" */
						res = ast_say_date_with_format_en(chan, t, ints, lang, "BdY", tzone);
} else if (beg_today + 2628000 < t)
{
	/* Less than 6 months from now - "August seventh" */
	res = ast_say_date_with_format_en(chan, t, ints, lang, "Bd", tzone);
}
else if (beg_today + 86400 * 6 < t)
{
	/* Less than a month from now - "Sunday, October third" */
	res = ast_say_date_with_format_en(chan, t, ints, lang, "ABd", tzone);
}
else if (beg_today + 172800 < t)
{
	/* Within the next week */
	res = ast_say_date_with_format_en(chan, t, ints, lang, "A", tzone);
}
else if (beg_today + 86400 < t)
{
	/* Tomorrow */
	res = wait_file(chan, ints, "digits/tomorrow", lang);
}
else if (beg_today < t)
{
	/* Today */
	res = wait_file(chan, ints, "digits/today", lang);
}
else if (beg_today - 86400 < t)
{
	/* Yesterday */
	res = wait_file(chan, ints, "digits/yesterday", lang);
}
else if (beg_today - 86400 * 6 < t)
{
	/* Within the last week */
	res = ast_say_date_with_format_en(chan, t, ints, lang, "A", tzone);
}
else if (beg_today - 2628000 < t)
{
	/* Less than a month ago - "Sunday, October third" */
	res = ast_say_date_with_format_en(chan, t, ints, lang, "ABd", tzone);
}
else if (beg_today - 15768000 < t)
{
	/* Less than 6 months ago - "August seventh" */
	res = ast_say_date_with_format_en(chan, t, ints, lang, "Bd", tzone);
}
else
{
	/* More than 6 months ago - "April nineteenth two thousand three" */
	res = ast_say_date_with_format_en(chan, t, ints, lang, "BdY", tzone);
}

Does it make sense?

The code i looked up has the same code for ‘Q’ and ‘q’

To have a code change considered, you need to submit it through issues.asterisk.org, after agreeing to the contributor agreement (if work for hire, your employer needs to agree).

This changes the behaviour outside of the area that could be considered buggy, so could only go in in a new major version.

Codiing the multiplications of 86400 would make it easier to see where the numbers came from.

The existing code doesn’t handle daylight saving time changes well. Covering larger past and future periods would make such anomalies last much longer, although the failure would be in terms of whether or not explicit years and months were included changing other than at midnight.

Changing whether the year is added at midday doesn’t seem a good idea to me.

I have a feeling there is an off by one issue, in non-leap years, in using 365 * 86400 / 2.

The day of the week is likely to be relevant for distant times, so it doesn’t make sense to suppress it for dates that are more than a week away.

I’d consider midnight to be the start of the day, so all the <'s are wrong, even in the original.

How can i accomplish that with the say.conf file? Te Q and q parameters are incomplete

I would have assumed that you could not.

How does the voicemail conf do that?

Oh the voicemail is only for previous dates

I imagine it relies on the C code, referenced above.

I haven’t followed the code through to see how say.conf fits in, but my guess is that there is no entry in English and the C code is used, and for other languages, say.conf is used, but doesn’t handle the full semantics of Q.

The cross reference to voicemail.conf suggests that the code was actually written to support voice mail, so future times were never a consideration.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.