GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Badger::Codec::Timestamp(3) User Contributed Perl Documentation Badger::Codec::Timestamp(3)

Badger::Codec::Timestamp - encode/decode a timestamp via Badger::Timestamp

    use Badger::Codec::Timestamp;
    use Badger::Timestamp 'Now';

    my $codec   = Badger::Codec::Timestamp->new();
    my $encoded = $codec->encode(Now);
    my $decoded = $codec->decode($encoded);

This module implements a subclass of Badger::Codec for encoded and decoding timestamps using the Badger::Timestamp module. It is trivially simple, existing only to provide a consistent API with other Badger::Codec modules. It is typically used as a codec for reading and writing timestamps to and from a file via the Badger::Filesystem modules.

    use Badger::Filesystem 'File';
    use Badger::Timestamp 'Now';
    
    my $stamp = Now;                     # current data/time
    my $file  = File(
        'example.ts',                   # filename
        { codec => 'timestamp' }        # specify timestamp codec
    );
    
    # write timestamp to file
    $file->data($stamp);
    
    # read timestamp from file
    $stamp = $file->data;

Encodes the timestamp passed as an argument. The argument can be a Badger::Timestamp object or any of the constructor parameters accepted by Badger::Timestamp. The following example demonstrates how this works in principle, although it should be noted that it's completely pointless in practice. It is sufficient to simply call "Now->timestamp" to serialise a Badger::Timestamp to text without the need for any codec module (in fact, that's all the "encode()" method does behind the scenes).

    use Badger::Timestamp 'Now';
    $encoded = Badger::Codec::Timestamp->encode(Now);

Decodes the encoded timestamp passed as the first argument. Returns a Badger::Timestamp object.

Andy Wardley <http://wardley.org/>

Copyright (C) 2012 Andy Wardley. All rights reserved.

Badger::Codecs, Badger::Codec, Badger::Timestamp
2016-12-12 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.