Angular 6 Date Pipe not showing anything on iPhone safari browser - ios

I'm using simple date pipe to format date which is working fine on web and android browsers but on IOS it's showing nothing. If I remove the PIPE and display data then it's shown but not with the PIPE.
{{race.race_date | date:'M/d/y'}}
You can check this issue on Issue link
Backend is returning data correctly.

UPDATE:
ah yes, the issue is with ios device only, you need to either use a custom pipe or convert the date to a date object. you can use moment but heres a custom pipe
<span>{{race.race_date | dateTimeFormatFilter : "MMM DD, YYYY"}}</span>
#Pipe({name: "dateTimeFormatFilter"})
#Injectable()
export class DateTimeFormatPipe implements PipeTransform {
transform(date: any, format: string): any {
if (date) {
return moment(date).format(format);
}
}
}

I ran into the same issue. I don't know how much local settings affect it, but here's what I have found.
The correct date format that works for me looks like this:
"2021-11-25T09:08:28"
I had problem with format "2021-11-25 09:08:28" so all I did is replace space with a 'T'.
In angular it looks like this:
{{ "2021-11-25 09:08:28".replace(' ', 'T') | date: 'dd.MM.' }}
As far as I know the date format after pipe, in my case 'dd.MM.', doesn't have affect on the problem. This format type also works in Chrome.

Related

Illegal sap.ui.model.odata.type.DateTimeOffset

Posting for prosperity. I had zero hits from google.
I'm writing a SAP Business One Web Client extension. I'm using the worklist template and have the b1s/v2/ Service Layer metadata (auto generated while setting up the template)
Running the sandbox version ("npm run start-local") it automatically generates fake data based on the metadata. My data included an edm.DateTimeOffset which is resolved by Fiori using the sap.ui.model.odata.type.DateTimeOffset model.
Here is an example response object from the test data proxy (all autogenerated)
{
DocEntry: 1,
U_CardCode: "U_CardCode_0",
U_CardName: "U_CardName_0",
U_DocCurrency: "U_DocCurrency_0",
U_DocTotal: "",
U_DueDate: "2017-04-13T14:50:39.000Z",
U_Status: "U_Status_0",
U_SupplierInvNo: "U_SupplierInvNo_0",
}
A perfectly normal U_DueDate value that, according to all the documentation I could find is an accepted format, doublely confirmed by the fact that it's a sap generated value.
This produces an error on screen
Illegal sap.ui.model.odata.type.DateTimeOffset
Adding a formatter doesn't work. If it's unable to parse the value then it won't pass it on to a formatter.
Turns out there is a way to override the expected type in the metadata. I couldn't find much documentation on it, but I changed the element from
text="{'U_DueDate'}" />
to
text="{
path: 'U_DueDate',
targetType: 'any',
formatter: '.formatter.date'
}" />
The date is now accepted as a string so I can use a custom formatter.
Here is the date function in the formetter:
date : function (sValue) {
if (!sValue) {
return "";
}
var date = new Date(sValue)
var asString = date.toLocaleDateString("en-GB")
return asString;
}
You don't have to hard code the localization, but my use case is that niche

How do you convert a date in XSLT2.0?

How can I format the resulted date below to display like this: MM/dd/YYYY (e.g.: 05/04/2020)?
The $getField will be: 2020-05-04T15:00:12
My value in the template is:
<xsl:value-of select="xs:dateTime($getField)+xs:dayTimeDuration('PT1H')"/>
Currently, it displays as follows: 2020-04-05T16:00:12
Each time I try using format-date, I get an error.
Also, if I will use xs:date(xs:dateTime($getField)+xs:dayTimeDuration('PT12H')), it will display only the date, without hours/minutes, but still not sure how can I change the order for date?
Thanks!
Use the format-dateTime() function with the desired picture "[M01]/[D01]/[Y0001]":
format-dateTime(xs:dateTime($getField)+xs:dayTimeDuration('PT1H'), "[M01]/[D01]/[Y0001]")

Prestashop convertPrice doesn't convert price

Using Prestashop 1.6.1.4
The theme function
{convertPrice price=$total}
Add the current currency sign but doesn't actually convert the to the chosen currency.
I followed the debugger to function (classes/Product.php, line 3034):
public static function convertPrice($params, &$smarty)
{
return Tools::displayPrice($params['price'], Context::getContext()->currency);
}
Which is strange since the convertPrice eventually calls displayPrice while Tools::convertPrice(...) is the function that convert the currency (but doesn't add the currency sign).
So I change it to :
return Tools::displayConvertPrice($params['price'], Context::getContext()->currency);
and added to Tools.php
public function displayConvertPrice($price, $currency)
{
return Tools::displayPrice(Tools::convertPrice($price, $currency), $currency);
}
My question:
Is it a bug or that I'm missing something?
Who knows what the devs wanted with that but there is a smarty function
{convertAndFormatPrice price=$total}
which does what you want.
You can open /config/smarty.config.inc.php and you'll see all prestashop functions registered in smarty smartyRegisterFunction(yada yada).
Use
{toolsConvertPrice price=$total}
this works for me on PS 1.6.1.12.

display seconds in DateTimeItem (SmartGWT)

when reading SmartGWT DateTimeItem: accept 12 hour format I found that using TimeDisplayFormat offers the options to display the seconds as, e.g. dateTimeItem.setTimeFormatter(TimeDisplayFormat.TOPADDED24HOURTIME); well, but there was no change in the displaying of the date.
As the code states that TimeDisplayFormat is deprecated, and one should use the DateDisplayFormatter instead, I tried dateTimeItem.setDateFormatter(DateDisplayFormat.TOSERIALIZEABLEDATE);, but still no change.
The value gets set via dateTimeItem.setValue(myDate);
Any idea what (else) I have to set to the DateTimeItem in order to get the seconds displayed as well?
I'm using SmartGWT 3.1
PS: I tried dateTimeItem.setDisplayFormat(DateDisplayFormat.TOSERIALIZEABLEDATE); as well, but still no change
It seems DateDisplayFormat.TOSERIALIZEABLEDATE is having some issue in SmartGWT 3.x.
dateTimeItem.setDateFormatter(DateDisplayFormat.TOSERIALIZEABLEDATE); works correctly in SmartGWT 4.0.
dateTimeItem.setDisplayFormat(DateDisplayFormat.TOSERIALIZEABLEDATE); did not provide required behavior even in 4.0, probably due to a default system wide format setting.
You should be able to use a value formatter as a workaround in 3.0.
dateTimeItem.setEditorValueFormatter(new FormItemValueFormatter() {
public String formatValue(Object value, Record record, DynamicForm form, FormItem item) {
if (value != null && value instanceof Date) {
return DateTimeFormat.getFormat("yyyy-MM-dd HH:mm:ss").format((Date) value);
}
return null;
}
});
Check DateItem.setEditorValueFormatter as you might have to set input format, etc. as well.
hi use the following code in your dateitem timeSheetDate.setShowPickerTimeItem(true); timeSheetDate.setTimeFormatter(TimeDisplayFormat.TOSHORTTIME); and also you can use timeSheetDate.setTimeFormatter(TimeDisplayFormat.TOTIME);

set data type when exporting to excel

I'm using Grails 1.3.4 with the export 0.9.5 plug in.
I have a formatter that I use that sets the date format to 'YYYY-MM-DD' when exporting to excel. But this doesn't change the data type. The date is exported to Excel as a string/general data type.
def dateFormat = { domain, value ->
if(value instanceof Date){
return new java.text.SimpleDateFormat("yyyy-MM-dd").format(value)
}
return value
}
Map formatters = [ecd:dateFormat, completed:dateFormat, dateCreated:dateFormat, approvedDate:dateFormat, dpaECD:dateFormat]
exportService.export(params.format, response.outputStream,exportList, jobService.parseColNames(columns), labels, formatters, null)
Is there a way to export data and set the datatype of a column in excel so the user doesn't have to manually set the cell/column formatting to 'Date' every time after exporting?
Are you sure you want to use that plugin? It didn't work so well to me.
I've been using the JXL plugin for Grails for a while and it works perfectly.
It even has an option to write the Excel file to the response, so that the user can directly download the file using my REST service.
The link is: http://grails.org/plugin/jxl
Here is an example of how simple it is to create workbooks:
new ExcelBuilder().workbook('/path/to/test.xls') {
sheet('SheetName') {
cell(0,0,'Current Date')
cell(0,1,new Date())
}
}
Note that the cell() method has 3 parameters: column, row and value. This third parameter can be a number, string or date, and it formats it perfectly.
You can find more information here.

Resources