Rate this feature
Included in the Nov. 2022 release The Celigo platform JavaScript runtime (JSRT) module provides native support for the dayjs library.
Note: The JSRT module does not support dayjs timezone.
Contents
Supported dayjs version
Library | License | Supported version | Description |
---|---|---|---|
dayjs | MIT | 1.11.0 | Widely used for parsing, validating, manipulating, and displaying date/time. If you've worked with Moment.js, then using dayjs is quite similar. |
Import dayjs
You can use the dayjs library after integrator.io imports it when the following statement is included at the start of your script:
import dayjs from 'dayjs'
Example: Call dayjs functions
Note: You can create a script using function stubs that are available within integrator.io. Select any required function stub and add the code with dayjs functions to your script, based on what you want to do in your flow.
If you want to find the billing status, call dayjs functions such as isBefore, isAfter, Plug In (quarterOfYear) to calculate the dates and send them to the destination application by mapping the required fields.
/*Script using the preSavePage function stub that includes dayjs functions*/ import dayjs from 'dayjs' import quarterOfYear from 'dayjs/plugin/quarterOfYear' // Import plugin function preSavePage (options) { dayjs.extend(quarterOfYear) var BillDate = options.data[0].enddate; /* Convert the date from ‘DD-MM-YYY’ to ‘YYYY-MM-DD’ format */ var BillingDate = dayjs(BillDate).format('YYYY-MM-DD') /* Return Boolean value if the bill date is still pending */ var PendingBillingDate = dayjs(BillDate).isBefore() /* Return Boolean value if the bill date is missed */ var MissedBillingDate = dayjs(BillDate).isAfter() /* Return quarterly term date */ var Quarterlyterm = dayjs(BillDate).quarter() options.data[0].BillingDate = BillingDate options.data[0].BillDate = BillDate options.data[0].PendingBillingDate = PendingBillingDate options.data[0].MissedBillingDate = MissedBillingDate options.data[0].Quarterlyterm = Quarterlyterm return { data: options.data, errors: options.errors, newErrorsAndRetryData: [] } }
Comments
0 comments
Please sign in to leave a comment.