Works
"{selectedDateTime,dateformat,yyyy-MM-dd_HH:mm}" ;
Fails
"{selectedDateTime,dateformat,yyyy-MM-ddTHH:mm}" ;
2019-05-10T13:45 is a sort of standardized format... But the T throws it off...
Expected?
dateformat - - expected results?
Moderator: Martin
Re: dateformat - - expected results?
Working as expected. T is not the date pattern available. To show a simple char/string inside the format, you have to single quote, 'T'
So the correct one should be.
So the correct one should be.
Code: Select all
select = "{selectedDateTime,dateformat,yyyy-MM-dd'T'HH:mm}" ;
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Re: dateformat - - expected results?
I ran into a similar problem, so I wanted to use a variable to hold the format... Made things worse, since I couldn't do
Code: Select all
{selectedDateTime,dateformat,datefmt}
Last edited by jassing on 15 Dec 2019 03:14, edited 1 time in total.
Re: dateformat - - expected results?
@jassing : You can't put variable inside the dateformat pattern directly. Use eval() and concat the string inside.
You can even decoupled out the time variable part.
Or even decoupled the format part, but I don't think you have to do that unless you are really get into creating your own custom function.
Code: Select all
datefmt = "yyyy-MM-dd'T'_HH:mm";
t = eval('"{triggertime,dateformat,' + datefmt + '}"');
Code: Select all
datefmt = "yyyy-MM-dd'T'_HH:mm";
t = eval('"{' + triggertime + ',dateformat,' + datefmt + '}"');
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Re: dateformat - - expected results?
Neat, I know it won't work... Now. but that would work not in script? For instance writing to a file?
Re: dateformat - - expected results?
You mean eval() + concat method? As long as the final result is what you want, then writing to a file should be correct too. I used to use one of these variable dateformatting before, and then I just make the formatting fixed instead. Better use more script lines than to confuse my future self.
It is just much harder to use eval when you combine too many variable inside. Because you have to take care of the single and double quote, the line separation (if needed) and especially when dealing with regex which can contain so many symbol character.
It is just much harder to use eval when you combine too many variable inside. Because you have to take care of the single and double quote, the line separation (if needed) and especially when dealing with regex which can contain so many symbol character.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.