mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
first layout for form edit
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
/**
|
||||
* Some utils for manipulating dates
|
||||
*
|
||||
* **WARNING** experimental
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -8,6 +10,8 @@
|
||||
* The date is valid for the same timezone as the date's locale
|
||||
*
|
||||
* Do not take time into account
|
||||
*
|
||||
* **Experimental**
|
||||
*/
|
||||
const dateToISO = (date) => {
|
||||
return [
|
||||
@@ -19,16 +23,36 @@ const dateToISO = (date) => {
|
||||
|
||||
/**
|
||||
* Return a date object from iso string formatted as YYYY-mm-dd
|
||||
*
|
||||
* **Experimental**
|
||||
*/
|
||||
const ISOToDate = (str) => {
|
||||
let
|
||||
let
|
||||
[year, month, day] = str.split('-');
|
||||
|
||||
return new Date(year, month-1, day);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a date object from iso string formatted as YYYY-mm-dd:HH:MM:ss+01:00
|
||||
*
|
||||
* **Experimental**
|
||||
*/
|
||||
const ISOToDatetime = (str) => {
|
||||
console.log(str);
|
||||
let
|
||||
[cal, times] = str.split('T'),
|
||||
[year, month, date] = cal.split('-'),
|
||||
[time, timezone] = cal.split(times.charAt(9)),
|
||||
[hours, minutes, seconds] = cal.split(':')
|
||||
;
|
||||
|
||||
return new Date(year, month-1, date, hours, minutes, seconds);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a date to ISO8601, valid for usage in api
|
||||
*
|
||||
*/
|
||||
const datetimeToISO = (date) => {
|
||||
let cal, time, offset;
|
||||
@@ -52,7 +76,6 @@ const datetimeToISO = (date) => {
|
||||
].join('');
|
||||
|
||||
let x = cal + 'T' + time + offset;
|
||||
console.log('return date', x);
|
||||
|
||||
return x;
|
||||
};
|
||||
@@ -60,5 +83,6 @@ const datetimeToISO = (date) => {
|
||||
export {
|
||||
dateToISO,
|
||||
ISOToDate,
|
||||
ISOToDatetime,
|
||||
datetimeToISO
|
||||
};
|
||||
|
Reference in New Issue
Block a user