github.com/argoproj/argo-cd@v1.8.7/ui/src/app/settings/components/utils.ts (about)

     1  export function convertExpiresInToSeconds(expiresIn: string): number {
     2      if (!expiresIn) {
     3          return 0;
     4      }
     5      const time = expiresIn.match('^([0-9]+)([smhd])$');
     6      const duration = parseInt(time[1], 10);
     7      let interval = 1;
     8      if (time[2] === 'm') {
     9          interval = 60;
    10      } else if (time[2] === 'h') {
    11          interval = 60 * 60;
    12      } else if (time[2] === 'd') {
    13          interval = 60 * 60 * 24;
    14      }
    15      return duration * interval;
    16  }
    17  
    18  export function validExpiresIn(expiresIn: string): boolean {
    19      if (!expiresIn) {
    20          return true;
    21      }
    22      return expiresIn.match('^([0-9]+)([smhd])$') !== null;
    23  }