The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

DateTime::Format::Salesforce - Parses datetime strings from the Salesforce API

SYNOPSIS

    use DateTime::Format::Salesforce;
    
    my $dt = DateTime::Format::Salesforce->parse_datetime( $str );
    
    or 
    
    my $parser = DateTime::Format::Salesforce->new;
    my $dt = $parser->parse_datetime( $str );
    

DESCRIPTION

Parses datetime formats returned by the Salesforce REST API. These claim to by ISO 8601 but subtly deviate from the standard, and hence can't be parsed by DateTime::Format::ISO8601. This code is based heavily on that module and supports only the formats received from Salesforce.

USAGE

Import Parameters

This module accepts no arguments to it's import method.

Methods

Constructors

  • new( ... )

    Accepts an optional hash.

        my $iso8601 = DateTime::Format::ISO8601->new(
                        base_datetime => $dt,
                        cut_off_year  => 42,
                        legacy_year   => 1,
                    );
    • base_datetime

      A DateTime object that will be used to fill in missing information from incomplete date/time formats.

      This key is optional.

    • cut_off_year

      A integer representing the cut-off point between interpreting 2-digits years as 19xx or 20xx.

          2-digit years <  legacy_year will be interpreted as 20xx
          2-digit years >= legacy_year will be untreated as 19xx

      This key defaults to the value of DefaultCutOffYear.

    • legacy_year

      A boolean value controlling if a 2-digit year is interpreted as being in the current century (unless a base_datetime is set) or if cut_off_year should be used to place the year in either 20xx or 19xx.

      This key defaults to the value of DefaultLegacyYear.

Object Methods

  • base_datetime

    Returns a DateTime object if a base_datetime has been set.

  • set_base_datetime( object => $object )

    Accepts a DateTime object that will be used to fill in missing information from incomplete date/time formats.

  • cut_off_year

    Returns a integer representing the cut-off point between interpreting 2-digits years as 19xx or 20xx.

  • set_cut_off_year( $int )

    Accepts a integer representing the cut-off point between interpreting 2-digits years as 19xx or 20xx.

        2-digit years <  legacy_year will be interpreted as 20xx
        2-digit years >= legacy_year will be interpreted as 19xx
  • legacy_year

    Returns a boolean value indicating the 2-digit year handling behavior.

  • set_legacy_year( $bool )

    Accepts a boolean value controlling if a 2-digit year is interpreted as being in the current century (unless a base_datetime is set) or if cut_off_year should be used to place the year in either 20xx or 19xx.

Class Methods

  • DefaultCutOffYear( $int )

    Accepts a integer representing the cut-off point for 2-digit years when calling parse_* as class methods and the default value for cut_off_year when creating objects. If called with no parameters this method will return the default value for cut_off_year.

  • DefaultLegacyYear( $bool )

    Accepts a boolean value controlling the legacy year behavior when calling parse_* as class methods and the default value for legacy_year when creating objects. If called with no parameters this method will return the default value for legacy_year.

Parser(s)

These may be called as either class or object methods.

  • parse_datetime

    Please see the "FORMATS" section.

FORMATS

  • YYYY-MM-DDThh:mm:ss.ss[+-]hhmm

        1999-11-02T23:12:00.456+0400

CREDITS

Credit to all the contributors to DateTime::Format::ISO8601 on whose work this module is shamelessly built.

SUPPORT

Support for this module is provided via the <datetime@perl.org> email list. See http://lists.perl.org/ for more details.

AUTHOR

Carl Vincent <carl.vincent@netskills.ac.uk>

COPYRIGHT

Copyright (c) 2012 Carl Vincent. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

The full text of the licenses can be found in the LICENSE file included with this module, or in perlartistic and perlgpl as supplied with Perl 5.8.1 and later.

SEE ALSO

DateTime, DateTime::Format::ISO8601, DateTime::Format::Builder, http://datetime.perl.org/