Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding ability to specify a date and time format #75

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,10 @@ service apparmor restart
""
],
"email_alert_to": "",
"sms_alert_to": ""
"sms_alert_to": "",
"ws_port": 8080,
"date_format": "YYYY-MM-DD",
"time_format": "HH:mm:ss"
}
</pre>

Expand Down
4 changes: 3 additions & 1 deletion config/glass_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,7 @@
],
"email_alert_to": "",
"sms_alert_to": "",
"ws_port": 8080
"ws_port": 8080,
"date_format": "YYYY-MM-DD",
"time_format": "HH:mm:ss"
}
47 changes: 36 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"jade": "~1.11.0",
"jsonfile": "^3.0.1",
"lodash": "^4.17.10",
"moment": "^2.29.1",
"morgan": "^1.9.0",
"nodemailer": "^4.6.7",
"serve-favicon": "^2.5.0",
Expand Down
26 changes: 5 additions & 21 deletions routes/dhcp_config_snapshots.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,13 @@ var router = express.Router();
var fs = require('fs');
var template_render = require('../core/render-template.js');
var authorize = require('../core/authorize.js');
var json_file = require('jsonfile');
var moment = require('moment');
var glass_config = json_file.readFileSync('config/glass_config.json');

function human_time (time){
var time = new Date(time);
var year = time.getFullYear();
var month = time.getMonth()+1;
var date1 = time.getDate();
var hour = time.getHours();
var minutes = time.getMinutes();
var seconds = time.getSeconds();

var hour = time.getHours();
var minute = time.getMinutes();
var amPM = (hour > 11) ? "PM" : "AM";
if(hour > 12) {
hour -= 12;
} else if(hour == 0) {
hour = "12";
}
if(minute < 10) {
minute = "0" + minute;
}

return year + "-" + month+"-"+date1+" "+hour + ":" + minute + ' ' + amPM;
var humantime = moment(time);
return humantime.format(glass_config.date_format + " " + glass_config.time_format)
}

router.get('/', authorize.auth, function(req, res, next) {
Expand Down
14 changes: 5 additions & 9 deletions routes/dhcp_lease_search.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,13 @@ var express = require('express');
var router = express.Router();
var fs = require('fs');
var template_render = require('../core/render-template.js');
var json_file = require('jsonfile');
var moment = require('moment');
var glass_config = json_file.readFileSync('config/glass_config.json');

function human_time (time){
var time = new Date(time);
var year = time.getFullYear();
var month = time.getMonth()+1;
var date1 = time.getDate();
var hour = time.getHours();
var minutes = time.getMinutes();
var seconds = time.getSeconds();

return year + "-" + month+"-"+date1+" "+hour+":"+minutes+":"+seconds;
var humantime = moment(time);
return humantime.format(glass_config.date_format + " " + glass_config.time_format)
}

router.post('/', function(req, res, next) {
Expand Down
14 changes: 5 additions & 9 deletions routes/dhcp_leases.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,13 @@ var express = require('express');
var router = express.Router();
var fs = require('fs');
var template_render = require('../core/render-template.js');
var json_file = require('jsonfile');
var moment = require('moment');
var glass_config = json_file.readFileSync('config/glass_config.json');

function human_time (time){
var time = new Date(time);
var year = time.getFullYear();
var month = time.getMonth()+1;
var date1 = time.getDate();
var hour = time.getHours();
var minutes = time.getMinutes();
var seconds = time.getSeconds();

return year + "-" + month+"-"+date1+" "+hour+":"+minutes+":"+seconds;
var humantime = moment(time);
return humantime.format(glass_config.date_format + " " + glass_config.time_format)
}

router.get('/', function(req, res, next) {
Expand Down
14 changes: 5 additions & 9 deletions routes/dhcp_log.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,13 @@ var express = require('express');
var router = express.Router();
var fs = require('fs');
var template_render = require('../core/render-template.js');
var json_file = require('jsonfile');
var moment = require('moment');
var glass_config = json_file.readFileSync('config/glass_config.json');

function human_time (time){
var time = new Date(time);
var year = time.getFullYear();
var month = time.getMonth()+1;
var date1 = time.getDate();
var hour = time.getHours();
var minutes = time.getMinutes();
var seconds = time.getSeconds();

return year + "-" + month+"-"+date1+" "+hour+":"+minutes+":"+seconds;
var humantime = moment(time);
return humantime.format(glass_config.date_format + " " + glass_config.time_format)
}

router.get('/', function(req, res, next) {
Expand Down