Socket
Socket
Sign inDemoInstall

gdate-julian

Package Overview
Dependencies
0
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.0 to 2.0.1

2

package.json
{
"name": "gdate-julian",
"version": "2.0.0",
"version": "2.0.1",
"description": "Converts date to and from julian days in gLib GDate style",

@@ -5,0 +5,0 @@ "type": "module",

@@ -1,2 +0,2 @@

# GDate (GLib) style julian days to and from gregorian date converter
hpore# GDate (GLib) style julian days to and from gregorian date converter
Port of GLib functions to work with julian days, to convert between it and gregorian date.

@@ -7,3 +7,3 @@ Library was initially developed to help a sister library [node-xhb](https://github.com/hertzg/node-xhb) work with

## Install
```javascript 1.8
```shell
npm install gdate-julian

@@ -14,27 +14,13 @@ ```

Import ESM style
```ecmascript 6
import {g_date_to_julian_days, g_julian_days_to_date} from 'gdate-julian'
```javascript
import {dateToJulianDays, julianDaysToDate} from 'gdate-julian'
```
or CJS Style
```javascript 1.8
const {g_date_to_julian_days, g_julian_days_to_date} = require('gdate-julian')
```
each method is also exported as `camelCase` alias:
```ecmascript 6
import {gDate2JulianDays, gJulianDays2Date} from 'gdate-julian'
```
or CJS Style
```javascript 1.8
const {gDate2JulianDays, gJulianDays2Date} = require('gdate-julian')
```
## Example
Here we show small example how to convert between Gregorian Date and Julian Days
More detailed examples can be found in tests in `./src/__tests__/g_date_conversion_spec.js`
More detailed examples can be found in tests in `./src/__tests__/date_conversion_spec.js`
### Gregorian Date to Julian Days
```ecmascript 6
const julianDays = gDate2JulianDays(new Date('1900-01-01T12:00:00Z'))
```javascript
const julianDays = dateToJulianDays(new Date('1900-01-01T12:00:00Z'))
console.log(julianDays) // outputs 693596

@@ -44,4 +30,4 @@ ```

### Julian Days to Gregorian Date
```ecmascript 6
const gregorianDate = gJulianDays2Date(693596)
```javascript
const gregorianDate = julianDaysToDate(693596)
console.log(gregorianDate) // outputs 1900-01-01T12:00:00Z

@@ -52,9 +38,4 @@ ```

Project also includes type definitions for TypeScript in `./src/index.d.ts`
```typescript
export type g_date_is_leap_year = (year: number) => boolean;
export type g_julian_days_to_date = (julian_days: number) => Date;
export type g_date_to_julian_days = (date: Date) => number;
```
## License
The code provided here is based off GLib codebase, hence licenced under same LGPL.
SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc