first layout for form edit

This commit is contained in:
2021-06-09 16:13:39 +02:00
parent 18217f53e8
commit e14205ae1d
16 changed files with 386 additions and 83 deletions

View File

@@ -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
};