Skip to content

Commit

Permalink
Merge pull request #695 from atomist/date-format-utc-1
Browse files Browse the repository at this point in the history
Default formatDate to UTC
  • Loading branch information
ddgenome committed Mar 29, 2019
2 parents 58ac7f6 + 5ab314b commit bb9ffe7
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions lib/api-helper/misc/dateFormat.ts
@@ -1,5 +1,5 @@
/*
* Copyright © 2018 Atomist, Inc.
* Copyright © 2019 Atomist, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -18,11 +18,15 @@ import * as df from "dateformat";

/**
* Format the date with provided format.
* Defaults to formatting the current date with 'yyyymmddHHMMss' format.
* @param date
* @param format
* Defaults to formatting the current UTC date with 'yyyymmddHHMMss' format.
*
* @param date Date object to format
* @param format dateformat compatible format
* @param utc if true, use UTC time, otherwise use local time zone
* @return properly formatted date string
*/
export function formatDate(date: Date = new Date(),
format: string = "yyyymmddHHMMss"): string {
return df(date, format);
format: string = "yyyymmddHHMMss",
utc: boolean = true): string {
return df(date, format, utc);
}

0 comments on commit bb9ffe7

Please sign in to comment.