Coder Social home page Coder Social logo

perl6-datetime-format-likego's Introduction

NAME

DateTime::Format::LikeGo - format dates using Go's reference format

SYNOPSIS

use DateTime::Format::LikeGo;

# Format a date
say go-date-format("2006-01-02", DateTime.now);

# convert to strftime format:
say DateTime::Format::LikeGo::go-to-strftime("2006-01-02"); # %Y-%m-%d

DESCRIPTION

A simple module that converts from Golang's "reference time" format to strftime. The intention is for you to specify how a certain datetime would be formatted, and it then can format any date in that style.

The reference date is 2006-01-02T15:04:05-0700, which is written as a series of ascending digits, if rearranged, and 3pm is used instead of 15.

Inspired by complaints about the Go time format.

FUNCTIONS

go-date-format(Str $format, DateTime $date) is export returns Str

Format the given time according to the provided format string.

go-to-strftime(Str $format) returns Str

Return the strftime version of the go format.

EXCEPTIONS

A string exception is thrown if the converted strftime format has any digits left over, which typically indicate a bad input format.

CAVEATS

  • Timezone support is missing in DateTime::Format, so strings using timezones will fail until it is added.
  • Not well tested overall.

REQUIREMENTS

  • Rakudo Perl 6 2014.11 or above. Tested primarily on MoarVM.
  • DateTime::Format

SEE ALSO

f***inggodateformat.com - inspiration for this module

Documentation for Go's time package

perl6-datetime-format-likego's People

Contributors

avuserow avatar zoffixznet avatar samcv avatar

Stargazers

Michal Jurosz avatar

Watchers

James Cloos avatar

perl6-datetime-format-likego's Issues

can't install see log bellow not sure if this is your prob or panda's

It always try's to find the stuff relative to where I run panda

panda  install DateTime::Format::LikeGo
==> Fetching DateTime::Format::LikeGo
==> Building DateTime::Format::LikeGo
==> Testing DateTime::Format::LikeGo
t/basic.t .. ok
All tests successful.
Files=1, Tests=3, 13 wallclock secs ( 0.05 usr  0.01 sys +  7.22 cusr  0.53 csys =  7.81 CPU)
Result: PASS
==> Installing DateTime::Format::LikeGo
Failed to copy '/home/grizzlysmit/.panda-work/1451268783_1/lib/DateTime/Format/LikeGo.pm' to '/home/grizzlysmit/.rakudobrew/moar-nom/install/share/perl6/site/sources/07AD8FE6319510008C5257C2CB81DC9B14963B10': Failed to copy file: no such file or directory
  in any  at /home/grizzlysmit/.rakudobrew/moar-nom/install/share/perl6/runtime/CORE.setting.moarvm line 1
  in block  at /home/grizzlysmit/.rakudobrew/moar-nom/install/share/perl6/site/sources/29F09C757412FD487CB148BC6EE267492959C486 line 61
  in sub indir at /home/grizzlysmit/.rakudobrew/moar-nom/install/share/perl6/site/sources/9B69159C1933BD092F0241E12217286E7A0B5A20 line 20
  in method install at /home/grizzlysmit/.rakudobrew/moar-nom/install/share/perl6/site/sources/29F09C757412FD487CB148BC6EE267492959C486 line 42
  in method install at /home/grizzlysmit/.rakudobrew/moar-nom/install/share/perl6/site/sources/090543F8DBD29804D76BAAC0103FF6D337DED39C line 146
  in method resolve at /home/grizzlysmit/.rakudobrew/moar-nom/install/share/perl6/site/sources/090543F8DBD29804D76BAAC0103FF6D337DED39C line 219
  in sub MAIN at /home/grizzlysmit/.rakudobrew/moar-nom/install/share/perl6/site/resources/6CE0986C872389704E6837E8E18FB8B60EA087C1 line 18
  in block  at /home/grizzlysmit/.rakudobrew/moar-nom/install/share/perl6/site/resources/6CE0986C872389704E6837E8E18FB8B60EA087C1 line 150

Actually thrown at:
  in any  at gen/moar/m-Metamodel.nqp line 3041
  in block  at /home/grizzlysmit/.rakudobrew/moar-nom/install/share/perl6/site/sources/29F09C757412FD487CB148BC6EE267492959C486 line 61
  in sub indir at /home/grizzlysmit/.rakudobrew/moar-nom/install/share/perl6/site/sources/9B69159C1933BD092F0241E12217286E7A0B5A20 line 20
  in method install at /home/grizzlysmit/.rakudobrew/moar-nom/install/share/perl6/site/sources/29F09C757412FD487CB148BC6EE267492959C486 line 42
  in method install at /home/grizzlysmit/.rakudobrew/moar-nom/install/share/perl6/site/sources/090543F8DBD29804D76BAAC0103FF6D337DED39C line 146
  in method resolve at /home/grizzlysmit/.rakudobrew/moar-nom/install/share/perl6/site/sources/090543F8DBD29804D76BAAC0103FF6D337DED39C line 219
  in sub MAIN at /home/grizzlysmit/.rakudobrew/moar-nom/install/share/perl6/site/resources/6CE0986C872389704E6837E8E18FB8B60EA087C1 line 18
  in block  at /home/grizzlysmit/.rakudobrew/moar-nom/install/share/perl6/site/resources/6CE0986C872389704E6837E8E18FB8B60EA087C1 line 150

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.