The Perl Advent Calendar needs more articles for 2022. Submit your idea today!


This example expands upon the Example::Types library defined in Type::Tiny::Manual::Libraries. It defines class types for DateTime and DateTime::Duration and some structured types for hashes that can be used to instantiate DateTime objects. It defines some coercions for the Datetime class type.

A simple Moose class is provided using some of these types and coercions. The class also defines a couple of extra coercions inline.

See the source code of this file for the actual example code.


Moose, DateTime.


Toby Inkster <>.


This software is copyright (c) 2013 by Toby Inkster.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.