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

Add an explict configurable default timezone to prevent issues with moment #224

Merged
merged 2 commits into from
Jul 18, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion server/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ class Config implements IConfig.Main {
cookieMaxAge: 1000 * 60 * 60 * 24 * 30 * 6, // 6 months
cookieSecureOnly: false,
mongoURL: "mongodb://localhost/",
passwordResetExpiration: 1000 * 60 * 60 // 1 hour
passwordResetExpiration: 1000 * 60 * 60, // 1 hour
defaultTimezone: "America/New_York"
};
public admins: string[] = [];
public eventName: string = "Untitled Event";
Expand Down Expand Up @@ -200,6 +201,9 @@ class Config implements IConfig.Main {
if (process.env.MONGO_URL) {
this.server.mongoURL = process.env.MONGO_URL!;
}
if (process.env.DEFAULT_TIMEZONE) {
this.server.defaultTimezone = process.env.DEFAULT_TIMEZONE;
}
if (process.env.PASSWORD_RESET_EXPIRATION) {
let expirationTime = parseInt(process.env.PASSWORD_RESET_EXPIRATION!, 10);
if (!isNaN(expirationTime) && expirationTime > 0) {
Expand Down
2 changes: 1 addition & 1 deletion server/routes/templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ templateRoutes.route("/").get(authenticateWithRedirect, async (request, response
function formatMoment(date: moment.Moment | null): string {
const FORMAT = "dddd, MMMM Do YYYY [at] h:mm a z";
if (date) {
return date.tz(moment.tz.guess()).format(FORMAT);
return date.tz(config.server.defaultTimezone).format(FORMAT);
}
return "(No branches configured)";
}
Expand Down
1 change: 1 addition & 0 deletions server/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export namespace IConfig {
cookieSecureOnly: boolean;
mongoURL: string;
passwordResetExpiration: number;
defaultTimezone: string;
}
export interface Style {
theme: string;
Expand Down