Improve Actions

This commit is contained in:
Peter Maquiran
2021-07-15 17:01:32 +01:00
parent 1c1c644268
commit 889e4a17dd
3 changed files with 78 additions and 4 deletions
@@ -14,6 +14,7 @@ import { Camera, CameraOptions } from '@ionic-native/camera/ngx';
import { ToastService } from 'src/app/services/toast.service';
import { FormControl, FormGroup, Validators } from '@angular/forms';
import { ThemePalette } from '@angular/material/core';
import { formatDate } from 'src/plugin/momentG.js'
@Component({
selector: 'app-new-publication',
@@ -218,13 +219,16 @@ export class NewPublicationPage implements OnInit {
}
else {
const date = formatDate(new Date(), 'yyyy-MM-dd HH:mm:ss')
alert(date)
this.publication = {
DateIndex: new Date().toLocaleString('pt'),
DateIndex: date,
DocumentId:null,
ProcessId:this.folderId,
Title: this.pub.Title,
Message: this.pub.Message,
DatePublication: new Date().toLocaleString('pt'),
DatePublication: date,
OriginalFileName: this.capturedImageTitle,
FileBase64: this.capturedImage,
FileExtension: 'jpeg',
@@ -119,6 +119,7 @@ export class PublicationDetailPage implements OnInit {
componentProps:{
publicationType: publicationType,
publication: this.publication,
folderId: this.folderId
},
cssClass: 'new-publication modal modal-desktop',
backdropDismiss: false
+71 -2
View File
@@ -60,5 +60,74 @@ class momentG {
}
module.exports = {
momentG: momentG.run
};
momentG: momentG.run,
formatDate: formatDate
};
var monthNames = [
"January", "February", "March", "April", "May", "June", "July",
"August", "September", "October", "November", "December"
];
var dayOfWeekNames = [
"Sunday", "Monday", "Tuesday",
"Wednesday", "Thursday", "Friday", "Saturday"
];
function formatDate(date, patternStr){
if (!patternStr) {
patternStr = 'M/d/yyyy';
}
var day = date.getDate(),
month = date.getMonth(),
year = date.getFullYear(),
hour = date.getHours(),
minute = date.getMinutes(),
second = date.getSeconds(),
miliseconds = date.getMilliseconds(),
h = hour % 12,
hh = twoDigitPad(h),
HH = twoDigitPad(hour),
mm = twoDigitPad(minute),
ss = twoDigitPad(second),
aaa = hour < 12 ? 'AM' : 'PM',
EEEE = dayOfWeekNames[date.getDay()],
EEE = EEEE.substr(0, 3),
dd = twoDigitPad(day),
M = month + 1,
MM = twoDigitPad(M),
MMMM = monthNames[month],
MMM = MMMM.substr(0, 3),
yyyy = year + "",
yy = yyyy.substr(2, 2)
;
// checks to see if month name will be used
patternStr = patternStr
.replace('hh', hh).replace('h', h)
.replace('HH', HH).replace('H', hour)
.replace('mm', mm).replace('m', minute)
.replace('ss', ss).replace('s', second)
.replace('S', miliseconds)
.replace('dd', dd).replace('d', day)
.replace('EEEE', EEEE).replace('EEE', EEE)
.replace('yyyy', yyyy)
.replace('yy', yy)
.replace('aaa', aaa);
if (patternStr.indexOf('MMM') > -1) {
patternStr = patternStr
.replace('MMMM', MMMM)
.replace('MMM', MMM);
}
else {
patternStr = patternStr
.replace('MM', MM)
.replace('M', M);
}
return patternStr;
}
function twoDigitPad(num) {
return num < 10 ? "0" + num : num;
}