all files / common/util/ DateUtils.ts

87.5% Statements 7/8
100% Branches 0/0
33.33% Functions 1/3
85.71% Lines 6/7
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28                                           
/*
 *  @license
 *  Copyright Hôpitaux Universitaires de Genève. All Rights Reserved.
 *
 *  Use of this source code is governed by an Apache-2.0 license that can be
 *  found in the LICENSE file at https://github.com/DSI-HUG/dejajs-components/blob/master/LICENSE
 */
 
import { DatePipe } from '@angular/common';
 
/**
 * Date conversion for DPI standards
 */
export class DateUtils {
    public static SYSTEM_DATE_FORMAT = 'yyyy-MM-dd HH:mm:ss';
 
    private static datePipe = new DatePipe('fr-CH');
 
    /**
     * Fromat a javascript date object to a 'yyyy-MM-dd HH:mm:ss' String Format
     * @param date
     */
    public static formatSystem(date: Date): string {
        return DateUtils.datePipe.transform(date, DateUtils.SYSTEM_DATE_FORMAT);
    }
}