Skip to content
Snippets Groups Projects
Select Git revision
  • f5a588eb5a25f3de31d66dbfeccca1a55cdfc5ef
  • main default protected
  • renovate/main-ghcr.io-renovatebot-base-image-11.x
  • chore/maintainers-rarkins
  • refactor/pin-new-value
  • fix/user-agent
  • feat/37517-base64-private-key
  • next
  • feat/gnupg
  • fix/36615b-branch-reuse-no-cache
  • chore/punycode
  • feat/36219--git-x509-signing
  • feat/structured-logger
  • hotfix/39.264.1
  • feat/skip-dangling
  • gh-readonly-queue/next/pr-36034-7a061c4ca1024a19e2c295d773d9642625d1c2be
  • hotfix/39.238.3
  • refactor/gitlab-auto-approve
  • feat/template-strings
  • gh-readonly-queue/next/pr-35654-137d934242c784e0c45d4b957362214f0eade1d7
  • fix/32307-global-extends-merging
  • 41.81.5
  • 41.81.4
  • 41.81.3
  • 41.81.2
  • 41.81.1
  • 41.81.0
  • 41.80.0
  • 41.79.0
  • 41.78.1
  • 41.78.0
  • 41.77.0
  • 41.76.1
  • 41.76.0
  • 41.75.0
  • 41.74.5
  • 41.74.4
  • 41.74.3
  • 41.74.2
  • 41.74.1
  • 41.74.0
41 results

index.ts

Blame
  • date.ts 947 B
    import { DateTime } from 'luxon';
    
    const ONE_MINUTE_MS = 60 * 1000;
    
    export function getElapsedDays(timestamp: string): number {
      const currentVersionTimestampDate = DateTime.fromISO(timestamp);
      const now = DateTime.now();
      const diffInDays = now.diff(currentVersionTimestampDate, 'days').as('days');
      const ageInDays = Math.floor(diffInDays);
      return ageInDays;
    }
    
    export function getElapsedMinutes(date: Date): number {
      return Math.floor((new Date().getTime() - date.getTime()) / ONE_MINUTE_MS);
    }
    
    export function getElapsedHours(date: Date | string): number {
      const pastDate =
        typeof date === 'string'
          ? DateTime.fromISO(date)
          : DateTime.fromJSDate(date);
    
      if (!pastDate.isValid) {
        return 0;
      }
    
      const diff = DateTime.now().diff(pastDate, 'hours');
      return Math.floor(diff.hours);
    }
    
    export function getElapsedMs(timestamp: string): number {
      return new Date().getTime() - new Date(timestamp).getTime();
    }