Coder Social home page Coder Social logo

dbix-class-inflatecolumn-timepiece's Introduction

Kwalitee status GitHub issues CPAN Cover Status Cpan license

NAME

DBIx::Class::InflateColumn::TimePiece - Auto-create Time::Piece objects from integer (number of seconds since epoch) columns

VERSION

version 0.03

SYNOPSIS

package Event;

use base 'DBIx::Class::Core';

__PACKAGE__->load_components(qw/InflateColumn::TimePiece/);
__PACKAGE__->table('my_events');
__PACKAGE__->add_columns(
    event_name => {
        data_type => 'varchar',
        size      => 45,
    },
    event_created => {
        data_type          => 'integer',
        inflate_time_piece => 1,
    },
);

1;

In the above example, a DBIx::Class named Event is created, then this DBIx::Class Component is loaded and two columns are added to the my_events table.

A column with data_type equal to integer or int and with property inflate_time_piece set to true, will be inflated using localtime in Time::Piece and deflated using the epoch method.

SEE ALSO

Development

The distribution is contained in a Git repository, so simply clone the repository

$ git clone git://github.com/reneeb/DBIx-Class-InflateColumn-TimePiece.git

and change into the newly-created directory.

$ cd DBIx-Class-InflateColumn-TimePiece

The project uses Dist::Zilla to build the distribution, hence this will need to be installed before continuing:

$ cpanm Dist::Zilla

To install the required prequisite packages, run the following set of commands:

$ dzil authordeps --missing | cpanm
$ dzil listdeps --author --missing | cpanm

The distribution can be tested like so:

$ dzil test

To run the full set of tests (including author and release-process tests), add the --author and --release options:

$ dzil test --author --release

AUTHOR

Renee Baecker [email protected]

COPYRIGHT AND LICENSE

This software is Copyright (c) 2018 by Renee Baecker.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)

dbix-class-inflatecolumn-timepiece's People

Contributors

reneeb avatar hakonhagland avatar

Watchers

 avatar James Cloos avatar

Forkers

hakonhagland

dbix-class-inflatecolumn-timepiece's Issues

Fails in most time zones

With TZ=UTC the test suite fails:

#   Failed test 'In: 1544536942 // Out: 2018-12-11 15:02:22'
#   at t/00_base.t line 64.
#          got: '2018-12-11 14:02:22'
#     expected: '2018-12-11 15:02:22'

#   Failed test 'In: -1 // Out: 1970-01-01'
#   at t/00_base.t line 64.
#          got: '1969-12-31'
#     expected: '1970-01-01'
# Looks like you failed 2 tests of 42.
t/00_base.t .............. 
Dubious, test returned 2 (wstat 512, 0x200)
Failed 2/42 subtests 

#   Failed test 'In: 1544536942 // Out: 2018-12-11 15:02:22'
#   at t/01_deflate.t line 50.
#          got: '2018-12-11 14:02:22'
#     expected: '2018-12-11 15:02:22'

#   Failed test 'In: -1 // Out: 1970-01-01'
#   at t/01_deflate.t line 50.
#          got: '1969-12-31'
#     expected: '1970-01-01'
# Looks like you failed 2 tests of 36.
t/01_deflate.t ........... 
Dubious, test returned 2 (wstat 512, 0x200)
Failed 2/36 subtests 

With TZ=Europe/Berlin it seems to pass mostly (but there are other potential problems --- without SQL::Translator the test suite also fails, and in some distributions perl comes without Time::Piece, so this one has to be declared as a prerequisite)

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.