/*
 * Copyright (C) SapphireCode - All Rights Reserved
 * This file is part of Snippeteer which is released under BSD-3-Clause.
 * See file 'LICENSE' for full license details.
 * Created by Timo Hocker <timo@scode.ovh>, May 2020
 */

import { CopyrightOptions } from './copyright_options';

export class CopyrightGenerator {
  public static get_copyright_notice (
    opt: CopyrightOptions,
    date_str?: string
  ): string {
    let notice = '';
    let date_string = date_str;
    if (typeof date_str === 'undefined') {
      const date = (new Date);
      const dtf = new Intl.DateTimeFormat ('en', { month: 'long' });
      const year = date.getFullYear ();
      const month = dtf.format (date);
      date_string = `${month} ${year}`;
    }

    if (opt.has_license) {
      notice = `${'/*'}
 * Copyright (C) ${opt.company || opt.author} - All Rights Reserved
 * This file is part of ${opt.software} which is released under ${
  opt.license}.
 * See file 'LICENSE' for full license details.
 * Created by ${opt.author} <${opt.email}>, ${date_string}
 */

`;
    }
    else {
      notice = `${'/*'}
 * Copyright (C) ${opt.company || opt.author} - All Rights Reserved
 * Created by ${opt.author} <${opt.email}>, ${date_string}
 */

`;
    }
    return notice;
  }
}