How to change dateformat in vue 3? - vue.js

I got the problem like this
2022-12-06T17:00:00.000Z
This is my code:
<Calendar
inputId="range"
v-model="collectionItems.StartOn"
selectionMode="range"
:manualInput="false"
dateFormat="yy-mm-dd"
>
</Calendar>
But I want like this
2022-12-05

To change the date format in Vuejs v3, you can use the date-fns.
npm install date-fns
and you can format date like bellow
var formatedDate = format(date, 'yyyy-MM-dd');
If you want to working code, I made it available on my codepen: https://codepen.io/maymeow/pen/xxzmgKJ
Hope it helps.

You have to format your collectionItems.StartOn before applying it to your custom component Calendar
Doest it come from your backend?
Either you parse it on your backend before sending it to your frontend, or you parse it via a JS date library like date-fns, dayjs or moment;
Install via yarn or npm and just follow the documentation ;)

Related

How to extract only date in react-native

I am using DateTimePicker in my react-native app.But when i try to get date in my text field it returns me something like that Monday June 21 2021 17:34:53 GMT.... but I want to get only date which is 2021:06:21 currently i am getting date like that new Date() and in my text I done like that <Text>{date.toString("yyyy-MM-dd")}</Text>
you can do
yourDate.toISOString().slice(0,10).replace(/-/g,"")
in jsx code
<Text>{yourDate.toISOString().slice(0,10).replace(/-/g,"")}</Text>
base this answer
OR
use moment library
<Text>{ moment(date).format('MM-DD-YYYY')}</Text>
Use moment
install moment
npm install moment --save
replace your text tag with this
<Text>{moment(date).format("MMM Do YY")}</Text>
ref : https://momentjs.com/
OR
you can also use toLocaleDateString() to get only date
<Text>{date.toLocaleDateString()}</Text>
OR
You can also convert first your date into string
<Text>{date.toString().substr(4 ,12)}</Text>
I would recommend using https://momentjs.com/.
then you can write moment(yourDate).format('MM/DD/YYYY'); or whatever format you want.

Is using Javascript in odoo.fields.HTML possible?

I want to integrate Adobe Captivate Content (Export: index.html, along with src-folder) into ODOO Community Edition v13 e-Learning Module (website_slides).
The slide.slide model already offers slide_type 'webpage' alongside the field 'html_content'.
The field 'html_content' is of type odoo.fields.HTML. To get the requirement stated above to work, I need to embed Javascript in the given html_content. It seems like the JS-scripts are not working. I also tried with a simple Hello World script.
Can someone help?
Best regards,
Lars
I found the solution already.
Looking at odoo/fields.py -> class Html, you can see that by default the given value is being sanitized using odoo/tools/mail.py -> html_sanitize(), which removes the HTML-Elements in 'tags_to_kill'. 'tags_to_kill' also contains "script".
After overriding html_content in slide.slide with the following, the Javascript-code is being executed:
html_content = fields.Html(
sanitize=False,
sanitize_tags=False,
sanitize_attributes=False)

Momentjs returns date in wrong timezone

I'm having a problem with momentjs. I'm trying to generate all days from a specific month by using the startOf and endOf methods on my moment object like this:
moment('2017-07-17').startOf('month')
However, when I log the return value in the console it returns "2017-06-30T22:00:00.000Z".
I expect it to just be "2017-07-01T00:00:00.000Z".
I am using vue 2.x if that makes any difference, and I'm importing moment like import moment from 'moment';.
Its because of timezone moment('2017-07-17') will take your local timezone which looks to be CEST.
instead do
moment.utc('2017-07-17')

How to generate unique id for each user at time of registration in react native?

For identifying each user i am trying to generate unique id at the time of registration in react native.How is it possible? Thanks in advance
the best way is using an UUID generator.
to install UUID generator use the two following cammands
$ npm install react-native-uuid-generator --save
$ react-native link react-native-uuid-generator
then import from 'react-native-uuid-generator'
import UUIDGenerator from 'react-native-uuid-generator';
for reference click here
You can set a timestamp for every user as id, but uuid is the best solution.

theming price format in drupal ubercart

What I am trying to achieve is to theme the price format the following way. I only want to remove the decimals when they are 00.
For example €5,00 should be €5, but €5,50 should remain the same, not €5,5.
I found a forum about this problem but I dont know how to implement it, especially overriding theme_uc_product_price() as suggested here.
Those links suggest using either the Computed Field Module or a Preprocess function but it would be simple with a bit of JQuery:
Let's say you have a div like so:
<div class="field-price">€ 5,00</div>
You could then target that element with a replace:
$('.field-price:contains(",00")').html(function(i, h) {
return h.replace(/00/g, '');
});​
I wrote a demo here:
http://jsfiddle.net/JySHQ/1/
Note please indicate what version of Drupal you have and then I give give you some hints as how to implement as Javascript is different in Drupal 6 vs. Drupal 7