DateTime::Format::Salesforce - Parses datetime strings from the Salesforce API
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 );
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.
This module accepts no arguments to it's import method.
import
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.
DateTime
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.
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.
DefaultLegacyYear
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.
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
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.
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.
parse_*
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.
These may be called as either class or object methods.
parse_datetime
Please see the "FORMATS" section.
YYYY-MM-DDThh:mm:ss.ss[+-]hhmm
1999-11-02T23:12:00.456+0400
Credit to all the contributors to DateTime::Format::ISO8601 on whose work this module is shamelessly built.
Support for this module is provided via the <datetime@perl.org> email list. See http://lists.perl.org/ for more details.
Carl Vincent <carl.vincent@netskills.ac.uk>
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.
DateTime, DateTime::Format::ISO8601, DateTime::Format::Builder, http://datetime.perl.org/
To install DateTime::Format::Salesforce, copy and paste the appropriate command in to your terminal.
cpanm
cpanm DateTime::Format::Salesforce
CPAN shell
perl -MCPAN -e shell install DateTime::Format::Salesforce
For more information on module installation, please visit the detailed CPAN module installation guide.