plasma-fhir
  • What is Plasma FHIR?
  • Docs
    • Guides
      • Getting Started
      • Create an Epic Patient App
      • Create an Epic Clinician App
      • Create an Epic Backend App
      • Testing with SMART Health IT Sandbox
      • Developing/Contributing to Plasma FHIR
  • Packages
    • create-plasma-app
    • plasma-fhir-app-utils
      • PlasmaFHIRApi
      • Resources
      • PlasmaFHIRUtils
      • Conversions
      • DateTimeUtils
    • plasma-fhir-backend-utils
    • plasma-fhir-react-client-context
    • plasma-fhir-react-components
  • Sample Apps
    • Plasma Portal
    • Plasma Portal Lite
    • Family History Editor
    • Playground
Powered by GitBook
On this page
  • fromString
  • getDOBFromAge
  • getAgeFromDOB
  1. Packages
  2. plasma-fhir-app-utils

DateTimeUtils

Utility functions for working with date/time objects.

import { DateTimeUtils } from "plasma-fhir-app-utils";

fromString

// Parse a string to a date...
const d = DateTimeUtils.fromString("1990-12-01");

getDOBFromAge

// Given an age, returns the highest/lowest possible DOB (relative to the given date)...
const dob = DateTimeUtils.getDOBFromAge(35, new Date());
console.log(dob.dobStart);
console.log(dob.dobEnd);

getAgeFromDOB

// Given a DOB, returns a person's age (relative to the given date)...
const date = DateTimeUtils.fromString("1990-12-01");
const age = DateTimeUtils.getAgeFromDOB(date, new Date());
PreviousConversionsNextplasma-fhir-backend-utils

Last updated 2 years ago