Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/djadala/yy

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/djadala/yy

  • v0.0.0-20170428033630-edf31d934188
  • Source
  • Go
  • Socket score

Version published
Created
Source

yy

Package yy converts incomplete dates to time.Time

Conversion is done by finding nearest valid date to reference date.

Incomplete dates are:

  • with missing year digits
  • with missing year and month
  • with missing year,month and day

Date validity is according std time package, for example no leap seconds

GoDoc

examples:

package main

import (
	"fmt"
	"github.com/djadala/yy"
	"time"
)

func main() {
	var d yy.IDate
	var ref = time.Date(2013, time.June, 10, 23, 1, 2, 3, time.UTC)

	d.Mo.SetI(2)
	d.D.SetI(29)

	r, err := yy.Convert(ref, &d)
	if err != nil {
		panic(err)
	}
	fmt.Println(r) // 29 Feb in  2013 is 2012-02-29
}

package main

import (
	"fmt"
	"github.com/djadala/yy"
	"time"
)

func main() {
	var ref = time.Date(2013, time.June, 10, 23, 1, 2, 3, time.UTC)

	r, err := yy.FromFormat([]byte("99-123"), []byte("YY-JJJ"), ref)
	if err != nil {
		panic(err)
	}
	fmt.Println(r) // year 99 julian day 123 in 2013 is 1999-05-03
}

FAQs

Package last updated on 28 Apr 2017

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