New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

js-excel-date-convert

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-excel-date-convert

Convert dates between JS and Excel formats

  • 1.0.2
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

📆 Convert between Excel and JS dates

This script takes into consideration the Leap-Year bug and the date difference between 1900 and 1904 Excel Date Systems.

Usage

// You can verify these results with the example at:
// https://docs.microsoft.com/en-us/office/troubleshoot/excel/1900-and-1904-date-system

const toExcelDate = require('js-excel-date-convert').toExcelDate;
const fromExcelDate = require('js-excel-date-convert').fromExcelDate;

const jul = new Date('jul 5 1998');

toExcelDate(jul);  // 35981 (1900 date system)

toExcelDate(jul, true); // 34519 (1904 date system)

fromExcelDate(35981); // "Sun, 05 Jul 1998 00:00:00 GMT"

fromExcelDate(34519, true);  // "Sun, 05 Jul 1998 00:00:00 GMT"

API

fromExcelDate(excelDate, date1904): Date

ParamTypeRequiredDescription
excelDatenumberyesAn integer number representing a date in Excel.
date1904booleannoSet this to true if the date is encoded in 1904 Date System. This is the default format for Excel in MacOS.

If you're using SheetJS you can check which system the file is using by calling wb.Workbook.WBProps.date1904

toExcelDate(date, date1904): number

ParamTypeRequiredDescription
dateDateyesDate to encode into Excel format.
date1904booleannoIf true, the date will be encoded to 1904 Date System. This is the default format for Excel in MacOS.

If you're using SheetJS you can check which system the file is using by calling wb.Workbook.WBProps.date1904

Credits

Raschid JF. Rafaelly

https://raschidjfr.dev

Keywords

FAQs

Package last updated on 06 Dec 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc