Catman...stamps(3pm)
π Catman...stamps(3pm) β User Contributed Perl Documentation π
okay bestie, sit down, hydrate, because we're about to talk about Catmandu::Plugin::Datestamps and honestly? it's giving "tiny plugin, enormous slay". π
β¨ NAME β¨
Catmandu::Plugin::Datestamps β automatically add datestamps to Catmandu::Store records πβ¨
like. it stamps dates. on your records. automatically. no cap.
π¦ SYNOPSIS π¦
first up, the config file route, because that's the vibe:
# Using configuration files
$ cat catmandu.yml
---
store:
test:
package: MongoDB
options:
database_name: test
bags:
data:
plugins:
- Datestamps
$ echo '{"hello":"world"}' | catmandu import JSON to test
$ catmandu export test to YAML
---
_id: ADA305D8-697D-11E3-B0C3-97AD572FA7E3
date_created: 2013-12-20T13:50:25Z
date_updated: 2013-12-20T13:50:25Z
hello: world
see how date_created and date_updated just appeared?? not me gasping. πβ¨ that's the plugin doing its lil thing.
or, if you're a Perl program kinda girlie, you can do it inline:
# Or in your Perl program
my $store = Catmandu::Store::MongoDB->new(
database_name => 'test' ,
bags => {
data => {
plugins => [qw(Datestamps)]
}
});
$store->bag->add({
'_id' => '123',
'name' => 'John Doe'
});
my $obj = $store->bag->get('123');
print "%s created at %s\n" , $obj->{name} , $obj->{date_created};
slay. you add a record, you get it back, the date is right there. main character behavior fr fr. π
πΈ DESCRIPTION πΈ
so here's the tea. the Catmandu::Plugin::Datestamps plugin automatically adds and updates datestamp fields in your records. that's it, that's the job, and it does it flawlessly. π
if you add this plugin to your Catmandu::Store configuration, then a date_created field and a date_updated field get added automatically to newly ingested records. like, you didn't ask, and yet. iconic. β¨
heads up bestie: you should set this plugin for every bag defined in yourCatmandu::Store. in the examples above we've set the plugin to the default bagdata, which is the one created in everyCatmandu::Store.
and here's the part where you gotta listen carefully π«Ά β in Catmandu::Stores that don't have a dynamic schema (thinking Solr, DBI), those new date fields should be predefined β like, by changing the schema.xml or the tables fields. do that or the vibe check fails. π
π CONFIGURATION π
datestamp_created_key
the field name where the creation date gets stored. defaults to date_created. it's also aliased as datestamp_created_field. two names, one legend. π
datestamp_updated_key
the field name where the update date gets stored. defaults to date_updated. also aliased as datestamp_updated_field. same energy. β¨
datestamp_format
want a custom strftime format? say less. peep Catmandu::Util::now for the possible format values π
my $store = Catmandu::Store::MyDB->new(bags => {book => {plugins =>
['Datestamps'], datestamp_format => '%Y/%m/%d'}});
my $store = Catmandu::Store::MyDB->new(bags => {book => {plugins =>
['Datestamps'], datestamp_format => 'iso_date_time_millis'}});
one is giving classic slashes, the other is giving iso_date_time_millis. both ate. π₯
π SEE ALSO π
Catmandu::StoreCatmandu::Bag
go read those, iykyk π¦
and that's the whole page, bestie!! this one shipped as perl v5.40.1, dated 2026-01-24, and it lives in your friendly neighborhood Catman...stamps(3pm) β user contributed Perl documentation, mwah π go forth and datestamp responsibly. π«Άβ¨
π¦ where this page comes from
- ubuntu resolute: libcatmandu-perl 1.2025-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libcatmandu-perl 1.2025-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms