DateTime - A date and time object for Perl
version 1.18
use DateTime;
$dt = DateTime->new(
year => 1964,
month => 10,
day => 16,
hour => 16,
minute => 12,
second => 47,
nanosecond => 500000000,
time_zone => 'Asia/Taipei',
);
$dt = DateTime->from_epoch( epoch => $epoch );
$dt = DateTime->now; # same as ( epoch => time() )
$year = $dt->year;
$month = $dt->month; # 1-12
$day = $dt->day; # 1-31
$dow = $dt->day_of_week; # 1-7 (Monday is 1)
$hour = $dt->hour; # 0-23
$minute = $dt->minute; # 0-59
$second = $dt->second; # 0-61 (leap seconds!)
$doy = $dt->day_of_year; # 1-366 (leap years)
$doq = $dt->day_of_quarter; # 1..
$qtr = $dt->quarter; # 1-4
# all of the start-at-1 methods above have corresponding start-at-0
# methods, such as $dt->day_of_month_0, $dt->month_0 and so on
$ymd = $dt->ymd; # 2002-12-06
$ymd = $dt->ymd('/'); # 2002/12/06
$mdy = $dt->mdy; # 12-06-2002
$mdy = $dt->mdy('/'); # 12/06/2002
$dmy = $dt->dmy; # 06-12-2002
$dmy = $dt->dmy('/'); # 06/12/2002
$hms = $dt->hms; # 14:02:29
$hms = $dt->hms('!'); # 14!02!29
$is_leap = $dt->is_leap_year;
# these are localizable, see Locales section
$month_name = $dt->month_name; # January, February, ...
$month_abbr = $dt->month_abbr; # Jan, Feb, ...
$day_name = $dt->day_name; # Monday, Tuesday, ...
$day_abbr = $dt->day_abbr; # Mon, Tue, ...
# May not work for all possible datetime, see the docs on this
# method for more details.
$epoch_time = $dt->epoch;
$dt2 = $dt + $duration_object;
$dt3 = $dt - $duration_object;
$duration_object = $dt - $dt2;
$dt->set( year => 1882 );
$dt->set_time_zone( 'America/Chicago' );
$dt->set_formatter( $formatter );
DateTime is a class for the representation of date/time combinations, and is part of the Perl DateTime project. For details on this project please see http://datetime.perl.org/. The DateTime site has a FAQ which may help answer many "how do I do X?" questions. The FAQ is at http://datetime.perl.org/wiki/datetime/page/FAQ.
It represents the Gregorian calendar, extended backwards in time before its creation (in 1582). This is sometimes known as the "proleptic Gregorian calendar". In this calendar, the first day of the calendar (the epoch), is the first day of year 1, which corresponds to the date which was (incorrectly) believed to be the birth of Jesus Christ.
The calendar represented does have a year 0, and in that way differs from how dates are often written using "BCE/CE" or "BC/AD".
For infinite datetimes, please see the DateTime::Infinite module.
The DateTime.pm module follows a simple consistent logic for determining whether or not a given number is 0-based or 1-based.
Month, day of month, day of week, and day of year are 1-based. Any method that is 1-based also has an equivalent 0-based method ending in "_0". So for example, this class provides both day_of_week()
and day_of_week_0()
methods.
The day_of_week_0()
method still treats Monday as the first day of the week.
All time-related numbers such as hour, minute, and second are 0-based.
Years are neither, as they can be both positive or negative, unlike any other datetime component. There is a year 0.
There is no quarter_0()
method.
Some errors may cause this module to die with an error string. This can only happen when calling constructor methods, methods that change the object, such as set()
, or methods that take parameters. Methods that retrieve information about the object, such as year()
or epoch()
, will never die.
All the object methods which return names or abbreviations return data based on a locale. This is done by setting the locale when constructing a DateTime object. If this is not set, then "en_US" is used.
The default time zone for new DateTime objects, except where stated otherwise, is the "floating" time zone. This concept comes from the iCal standard. A floating datetime is one which is not anchored to any particular time zone. In addition, floating datetimes do not include leap seconds, since we cannot apply them without knowing the datetime's time zone.
The results of date math and comparison between a floating datetime and one with a real time zone are not really valid, because one includes leap seconds and the other does not. Similarly, the results of datetime math between two floating datetimes and two datetimes with time zones are not really comparable.
If you are planning to use any objects with a real time zone, it is strongly recommended that you do not mix these with floating datetimes.
If you are going to be doing date math, please read the section "How DateTime Math Works".
If $ENV{TZ}
is not set, it may involve reading a number of files in /etc or elsewhere. If you know that the local time zone won't change while your code is running, and you need to make many objects for the local time zone, it is strongly recommended that you retrieve the local time zone once and cache it:
our $App::LocalTZ = DateTime::TimeZone->new( name => 'local' );
... # then everywhere else
my $dt = DateTime->new( ..., time_zone => $App::LocalTZ );
DateTime itself does not do this internally because local time zones can change, and there's no good way to determine if it's changed without doing all the work to look it up.
Do not try to use named time zones (like "America/Chicago") with dates very far in the future (thousands of years). The current implementation of DateTime::TimeZone
will use a huge amount of memory calculating all the DST changes from now until the future date. Use UTC or the floating time zone and you will be safe.
Internally, dates are represented the number of days before or after 0001-01-01. This is stored as an integer, meaning that the upper and lower bounds are based on your Perl's integer size ($Config{ivsize}
).
The limit on 32-bit systems is around 2^29 days, which gets you to year (+/-)1,469,903. On a 64-bit system you get 2^62 days, (+/-)12,626,367,463,883,278 (12.626 quadrillion).
DateTime provide many methods. The documentation breaks them down into groups based on what they do (constructor, accessors, modifiers, etc.).
All constructors can die when invalid parameters are given.
Currently, constructors will warn if you try to create a far future DateTime (year >= 5000) with any time zone besides floating or UTC. This can be very slow if the time zone has future DST transitions that need to be calculated. If the date is sufficiently far in the future this can be really slow (minutes).
All warnings from DateTime use the DateTime
category and can be suppressed with:
no warnings 'DateTime';
This warning may be removed in the future if DateTime::TimeZone is made much faster.
This class method accepts parameters for each date and time component: "year", "month", "day", "hour", "minute", "second", "nanosecond". It also accepts "locale", "time_zone", and "formatter" parameters.
my $dt = DateTime->new(
year => 1966,
month => 10,
day => 25,
hour => 7,
minute => 15,
second => 47,
nanosecond => 500000000,
time_zone => 'America/Chicago',
);
DateTime validates the "month", "day", "hour", "minute", and "second", and "nanosecond" parameters. The valid values for these parameters are:
month
An integer from 1-12.
day
An integer from 1-31, and it must be within the valid range of days for the specified month.
hour
An integer from 0-23.
minute
An integer from 0-59.
second
An integer from 0-61 (to allow for leap seconds). Values of 60 or 61 are only allowed when they match actual leap seconds.
nanosecond
An integer >= 0. If this number is greater than 1 billion, it will be normalized into the second value for the DateTime object.
Invalid parameter types (like an array reference) will cause the constructor to die.
The value for seconds may be from 0 to 61, to account for leap seconds. If you give a value greater than 59, DateTime does check to see that it really matches a valid leap second.
All of the parameters are optional except for "year". The "month" and "day" parameters both default to 1, while the "hour", "minute", "second", and "nanosecond" parameters all default to 0.
The "locale" parameter should be a string matching one of the valid locales, or a DateTime::Locale
object. See the DateTime::Locale documentation for details.
The time_zone parameter can be either a scalar or a DateTime::TimeZone
object. A string will simply be passed to the DateTime::TimeZone->new
method as its "name" parameter. This string may be an Olson DB time zone name ("America/Chicago"), an offset string ("+0630"), or the words "floating" or "local". See the DateTime::TimeZone
documentation for more details.
The default time zone is "floating".
The "formatter" can be either a scalar or an object, but the class specified by the scalar or the object must implement a format_datetime()
method.
This module does not parse dates! That means there is no constructor to which you can pass things like "March 3, 1970 12:34".
Instead, take a look at the various DateTime::Format::*
modules on CPAN. These parse all sorts of different date formats, and you're bound to find something that can handle your particular needs.
Because of Daylight Saving Time, it is possible to specify a local time that is ambiguous. For example, in the US in 2003, the transition from to saving to standard time occurred on October 26, at 02:00:00 local time. The local clock changed from 01:59:59 (saving time) to 01:00:00 (standard time). This means that the hour from 01:00:00 through 01:59:59 actually occurs twice, though the UTC time continues to move forward.
If you specify an ambiguous time, then the latest UTC time is always used, in effect always choosing standard time. In this case, you can simply subtract an hour to the object in order to move to saving time, for example:
# This object represent 01:30:00 standard time
my $dt = DateTime->new(
year => 2003,
month => 10,
day => 26,
hour => 1,
minute => 30,
second => 0,
time_zone => 'America/Chicago',
);
print $dt->hms; # prints 01:30:00
# Now the object represent 01:30:00 saving time
$dt->subtract( hours => 1 );
print $dt->hms; # still prints 01:30:00
Alternately, you could create the object with the UTC time zone, and then call the set_time_zone()
method to change the time zone. This is a good way to ensure that the time is not ambiguous.
Another problem introduced by Daylight Saving Time is that certain local times just do not exist. For example, in the US in 2003, the transition from standard to saving time occurred on April 6, at the change to 2:00:00 local time. The local clock changes from 01:59:59 (standard time) to 03:00:00 (saving time). This means that there is no 02:00:00 through 02:59:59 on April 6!
Attempting to create an invalid time currently causes a fatal error. This may change in future version of this module.
This class method can be used to construct a new DateTime object from an epoch time instead of components. Just as with the new()
method, it accepts "time_zone", "locale", and "formatter" parameters.
If the epoch value is not an integer, the part after the decimal will be converted to nanoseconds. This is done in order to be compatible with Time::HiRes
. If the floating portion extends past 9 decimal places, it will be truncated to nine, so that 1.1234567891 will become 1 second and 123,456,789 nanoseconds.
By default, the returned object will be in the UTC time zone.
This class method is equivalent to calling from_epoch()
with the value returned from Perl's time()
function. Just as with the new()
method, it accepts "time_zone" and "locale" parameters.
By default, the returned object will be in the UTC time zone.
This class method is equivalent to:
DateTime->now(@_)->truncate( to => 'day' );
This class method can be used to construct a new DateTime object from any object that implements the utc_rd_values()
method. All DateTime::Calendar
modules must implement this method in order to provide cross-calendar compatibility. This method accepts a "locale" and "formatter" parameter
If the object passed to this method has a time_zone()
method, that is used to set the time zone of the newly created DateTime.pm
object.
Otherwise, the returned object will be in the floating time zone.
This constructor takes the same arguments as can be given to the new()
method, except for "day". Additionally, both "year" and "month" are required.
This constructor takes the same arguments as can be given to the new()
method, except that it does not accept a "month" or "day" argument. Instead, it requires both "year" and "day_of_year". The day of year must be between 1 and 366, and 366 is only allowed for leap years.
This object method returns a new object that is replica of the object upon which the method is called.
This class has many methods for retrieving information about an object.
Returns the year.
Returns the year according to the BCE/CE numbering system. The year before year 1 in this system is year -1, aka "1 BCE".
Returns the long name of the current era, something like "Before Christ". See the Locales section for more details.
Returns the abbreviated name of the current era, something like "BC". See the Locales section for more details.
Returns a string, either "BC" or "AD", according to the year.
Returns a string, either "BCE" or "CE", according to the year.
Returns a string containing the year immediately followed by its era abbreviation. The year is the absolute value of ce_year()
, so that year 1 is "1AD" and year 0 is "1BC".
Like year_with_era()
, but uses the christian_era() method to get the era name.
Like year_with_era()
, but uses the secular_era() method to get the era name.
Returns the month of the year, from 1..12.
Also available as $dt->mon()
.
Returns the name of the current month. See the Locales section for more details.
Returns the abbreviated name of the current month. See the Locales section for more details.
Returns the day of the month, from 1..31.
Also available as $dt->mday()
and $dt->day_of_month()
.
Returns the day of the week as a number, from 1..7, with 1 being Monday and 7 being Sunday.
Also available as $dt->wday()
and $dt->dow()
.
Returns the day of the week as a number, from 1..7. The day corresponding to 1 will vary based on the locale.
Returns the name of the current day of the week. See the Locales section for more details.
Returns the abbreviated name of the current day of the week. See the Locales section for more details.
Returns the day of the year.
Also available as $dt->doy()
.
Returns the quarter of the year, from 1..4.
Returns the name of the current quarter. See the Locales section for more details.
Returns the abbreviated name of the current quarter. See the Locales section for more details.
Returns the day of the quarter.
Also available as $dt->doq()
.
Returns a number from 1..5 indicating which week day of the month this is. For example, June 9, 2003 is the second Monday of the month, and so this method returns 2 for that day.
Each method returns the year, month, and day, in the order indicated by the method name. Years are zero-padded to four digits. Months and days are 0-padded to two digits.
By default, the values are separated by a dash (-), but this can be overridden by passing a value to the method.
The $dt->ymd()
method is also available as $dt->date()
.
Returns the hour of the day, from 0..23.
Returns the hour of the day, from 1..24.
Returns the hour of the day, from 1..12.
Returns the hour of the day, from 0..11.
Returns the appropriate localized abbreviation, depending on the current hour.
Returns the minute of the hour, from 0..59.
Also available as $dt->min()
.
Returns the second, from 0..61. The values 60 and 61 are used for leap seconds.
Also available as $dt->sec()
.
Returns the second, as a real number from 0.0 until 61.999999999
The values 60 and 61 are used for leap seconds.
Returns the fractional part of the second as milliseconds (1E-3 seconds).
Half a second is 500 milliseconds.
This value will always be rounded down to the nearest integer.
Returns the fractional part of the second as microseconds (1E-6 seconds).
Half a second is 500_000 microseconds.
This value will always be rounded down to the nearest integer.
Returns the fractional part of the second as nanoseconds (1E-9 seconds).
Half a second is 500_000_000 nanoseconds.
Returns the hour, minute, and second, all zero-padded to two digits. If no separator is specified, a colon (:) is used by default.
Also available as $dt->time()
.
This method is equivalent to:
$dt->ymd('-') . 'T' . $dt->hms(':')
Also available as $dt->iso8601()
.
This method returns a true or false indicating whether or not the datetime object is in a leap year.
($week_year, $week_number) = $dt->week;
Returns information about the calendar week which contains this datetime object. The values returned by this method are also available separately through the week_year and week_number methods.
The first week of the year is defined by ISO as the one which contains the fourth day of January, which is equivalent to saying that it's the first week to overlap the new year by at least four days.
Typically the week year will be the same as the year that the object is in, but dates at the very beginning of a calendar year often end up in the last week of the prior year, and similarly, the final few days of the year may be placed in the first week of the next year.
Returns the year of the week. See $dt->week()
for details.
Returns the week of the year, from 1..53. See $dt->week()
for details.
The week of the month, from 0..5. The first week of the month is the first week that contains a Thursday. This is based on the ICU definition of week of month, and correlates to the ISO8601 week of year definition. A day in the week before the week with the first Thursday will be week 0.
These return the Julian Day and Modified Julian Day, respectively. The value returned is a floating point number. The fractional portion of the number represents the time portion of the datetime.
This returns the DateTime::TimeZone
object for the datetime object.
This returns the offset from UTC, in seconds, of the datetime object according to the time zone.
Returns a boolean indicating whether or not the datetime object is currently in Daylight Saving Time or not.
This is a shortcut for $dt->time_zone->name
. It's provided so that one can use "%{time_zone_long_name}" as a strftime format specifier.
This method returns the time zone abbreviation for the current time zone, such as "PST" or "GMT". These names are not definitive, and should not be used in any application intended for general use by users around the world.
This method implements functionality similar to the strftime()
method in C. However, if given multiple format strings, then it will return multiple scalars, one for each format string.
See the "strftime Patterns" section for a list of all possible strftime patterns.
If you give a pattern that doesn't exist, then it is simply treated as text.
This method implements formatting based on the CLDR date patterns. If given multiple format strings, then it will return multiple scalars, one for each format string.
See the "CLDR Patterns" section for a list of all possible CLDR patterns.
If you give a pattern that doesn't exist, then it is simply treated as text.
Return the UTC epoch value for the datetime object. Internally, this is implemented using Time::Local
, which uses the Unix epoch even on machines with a different epoch (such as MacOS). Datetimes before the start of the epoch will be returned as a negative number.
The return value from this method is always an integer.
Since the epoch does not account for leap seconds, the epoch time for 1972-12-31T23:59:60 (UTC) is exactly the same as that for 1973-01-01T00:00:00.
This module uses Time::Local
to calculate the epoch, which may or may not handle epochs before 1904 or after 2038 (depending on the size of your system's integers, and whether or not Perl was compiled with 64-bit int support).
Returns the epoch as a floating point number. The floating point portion of the value represents the nanosecond value of the object. This method is provided for compatibility with the Time::HiRes
module.
Note that this method suffers from the imprecision of floating point numbers, and the result may end up rounded to an arbitrary degree depending on your platform.
my $dt = DateTime->new( year => 2012, nanosecond => 4 );
say $dt->hires_epoch();
On my system, this simply prints<PHONE_NUMBER>
because adding 0.000000004
to<PHONE_NUMBER>
returns<PHONE_NUMBER>
.
These methods allow you to distinguish normal datetime objects from infinite ones. Infinite datetime objects are documented in DateTime::Infinite.
Returns the current UTC Rata Die days, seconds, and nanoseconds as a three element list. This exists primarily to allow other calendar modules to create objects based on the values provided by this object.
Returns the current local Rata Die days, seconds, and nanoseconds as a three element list. This exists for the benefit of other modules which might want to use this information for date math, such as DateTime::Event::Recurrence
.
Returns the number of leap seconds that have happened up to the datetime represented by the object. For floating datetimes, this always returns 0.
Returns the current UTC Rata Die days and seconds purely as seconds. This number ignores any fractional seconds stored in the object, as well as leap seconds.
Returns the current locale object.
Returns current formatter object or class. See "Formatters And Stringification" for details.
The remaining methods provided by DateTime.pm
, except where otherwise specified, return the object itself, thus making method chaining possible. For example:
my $dt = DateTime->now->set_time_zone( 'Australia/Sydney' );
my $first = DateTime
->last_day_of_month( year => 2003, month => 3 )
->add( days => 1 )
->subtract( seconds => 1 );
This method can be used to change the local components of a date time, or its locale. This method accepts any parameter allowed by the new()
method except for "time_zone". Time zones may be set using the set_time_zone()
method.
This method performs parameters validation just as is done in the new()
method.
Do not use this method to do date math. Use the add()
and subtract()
methods instead.
DateTime has a set_*
method for every item that can be passed to the constructor:
$dt->set_year()
$dt->set_month()
$dt->set_day()
$dt->set_hour()
$dt->set_minute()
$dt->set_second()
$dt->set_nanosecond()
$dt->set_locale()
These are shortcuts to calling set()
with a single key. They all take a single parameter.
This method allows you to reset some of the local time components in the object to their "zero" values. The "to" parameter is used to specify which values to truncate, and it may be one of "year", "month", "week", "local_week" "day", "hour", "minute", or "second". For example, if "month" is specified, then the local day becomes 1, and the hour, minute, and second all become 0.
If "week" is given, then the datetime is set to the Monday of the week in which it occurs, and the time components are all set to 0. If you truncate to "local_week", then the first day of the week is locale-dependent. For example, in the en_US
locale, the first day of the week is Sunday.
This method accepts either a time zone object or a string that can be passed as the "name" parameter to DateTime::TimeZone->new()
. If the new time zone's offset is different from the old time zone, then the local time is adjusted accordingly.
For example:
my $dt = DateTime->new(
year => 2000,
month => 5,
day => 10,
hour => 15,
minute => 15,
time_zone => 'America/Los_Angeles',
);
print $dt->hour; # prints 15
$dt->set_time_zone( 'America/Chicago' );
print $dt->hour; # prints 17
If the old time zone was a floating time zone, then no adjustments to the local time are made, except to account for leap seconds. If the new time zone is floating, then the UTC time is adjusted in order to leave the local time untouched.
Fans of Tsai Ming-Liang's films will be happy to know that this does work:
my $dt = DateTime->now( time_zone => 'Asia/Taipei' );
$dt->set_time_zone( 'Europe/Paris' );
Yes, now we can know "ni3 na4 bian1 ji2dian3?"
Set the formatter for the object. See "Formatters And Stringification" for details.
You can set this to undef
to revert to the default formatter.
Like the set methods, math related methods always return the object itself, to allow for chaining:
$dt->add( days => 1 )->subtract( seconds => 1 );
This returns DateTime::Duration
, but exists so that a subclass of DateTime.pm
can provide a different value.
This method adds a DateTime::Duration
to the current datetime. See the DateTime::Duration docs for more details.
This method is syntactic sugar around the add_duration()
method. It simply creates a new DateTime::Duration
object using the parameters given, and then calls the add_duration()
method.
When given a DateTime::Duration
object, this method simply calls invert()
on that object and passes that new duration to the add_duration
method.
Like add()
, this is syntactic sugar for the subtract_duration()
method.
This method returns a new DateTime::Duration
object representing the difference between the two dates. The duration is relative to the object from which $datetime
is subtracted. For example:
2003-03-15 00:00:00.00000000
- 2003-02-15 00:00:00.00000000
-------------------------------
= 1 month
Note that this duration is not an absolute measure of the amount of time between the two datetimes, because the length of a month varies, as well as due to the presence of leap seconds.
The returned duration may have deltas for months, days, minutes, seconds, and nanoseconds.
Each of these methods returns a new DateTime::Duration
object representing some portion of the difference between two datetimes. The delta_md()
method returns a duration which contains only the month and day portions of the duration is represented. The delta_days()
method returns a duration which contains only days.
The delta_md
and delta_days
methods truncate the duration so that any fractional portion of a day is ignored. Both of these methods operate on the date portion of a datetime only, and so effectively ignore the time zone.
Unlike the subtraction methods, these methods always return a positive (or zero) duration.
Returns a duration which contains only minutes and seconds. Any day and month differences to minutes are converted to minutes and seconds. This method also always return a positive (or zero) duration.
This method returns a new DateTime::Duration
object representing the difference between the two dates in seconds and nanoseconds. This is the only way to accurately measure the absolute amount of time between two datetimes, since units larger than a second do not represent a fixed number of seconds.
Note that because of leap seconds, this may not return the same result as doing this math based on the value returned by $dt->epoch()
.
This can be used to specify the default locale to be used when creating DateTime objects. If unset, then "en_US" is used.
$cmp = DateTime->compare( $dt1, $dt2 );
$cmp = DateTime->compare_ignore_floating( $dt1, $dt2 );
Compare two DateTime objects. The semantics are compatible with Perl's sort()
function; it returns -1 if $dt1 < $dt2, 0 if $dt1 == $dt2, 1 if $dt1 > $dt2.
If one of the two DateTime objects has a floating time zone, it will first be converted to the time zone of the other object. This is what you want most of the time, but it can lead to inconsistent results when you compare a number of DateTime objects, some of which are floating, and some of which are in other time zones.
If you want to have consistent results (because you want to sort a number of objects, for example), you can use the compare_ignore_floating()
method:
@dates = sort { DateTime->compare_ignore_floating($a, $b) } @dates;
In this case, objects with a floating time zone will be sorted as if they were UTC times.
Since DateTime objects overload comparison operators, this:
@dates = sort @dates;
is equivalent to this:
@dates = sort { DateTime->compare($a, $b) } @dates;
DateTime objects can be compared to any other calendar class that implements the utc_rd_values()
method.
If you are trying to test code that calls uses DateTime, you may want to be able to explicitly set the value returned by Perl's time()
builtin. This builtin is called by DateTime->now()
and DateTime->today()
.
You can override CORE::GLOBAL::time()
, but this will only work if you do this before loading DateTime. If doing this is inconvenient, you can also override DateTime::_core_time()
:
no warnings 'redefine';
local *DateTime::_core_time = sub { return 42 };
DateTime is guaranteed to core this subroutine to get the current time()
value. You can also override the _core_time()
sub in a subclass of DateTime and use that.
It's important to have some understanding of how datetime math is implemented in order to effectively use this module and DateTime::Duration
.
If you want to simplify your life and not have to think too hard about the nitty-gritty of datetime math, I have several recommendations:
use the floating time zone
If you do not care about time zones or leap seconds, use the "floating" timezone:
my $dt = DateTime->now( time_zone => 'floating' );
Math done on two objects in the floating time zone produces very predictable results.
Note that in most cases you will want to start by creating an object in a specific zone and then convert it to the floating time zone. When an object goes from a real zone to the floating zone, the time for the object remains the same.
This means that passing the floating zone to a constructor may not do what you want.
my $dt = DateTime->now( time_zone => 'floating' );
is equivalent to
my $dt = DateTime->now( time_zone => 'UTC' )->set_time_zone('floating');
This might not be what you wanted. Instead, you may prefer to do this:
my $dt = DateTime->now( time_zone => 'local' )->set_time_zone('floating');
use UTC for all calculations
If you do care about time zones (particularly DST) or leap seconds, try to use non-UTC time zones for presentation and user input only. Convert to UTC immediately and convert back to the local time zone for presentation:
my $dt = DateTime->new( %user_input, time_zone => $user_tz );
$dt->set_time_zone('UTC');
# do various operations - store it, retrieve it, add, subtract, etc.
$dt->set_time_zone($user_tz);
print $dt->datetime;
math on non-UTC time zones
If you need to do date math on objects with non-UTC time zones, please read the caveats below carefully. The results DateTime.pm
produces are predictable and correct, and mostly intuitive, but datetime math gets very ugly when time zones are involved, and there are a few strange corner cases involving subtraction of two datetimes across a DST change.
If you can always use the floating or UTC time zones, you can skip ahead to Leap Seconds and Date Math
date vs datetime math
If you only care about the date (calendar) portion of a datetime, you should use either delta_md()
or delta_days()
, not subtract_datetime()
. This will give predictable, unsurprising results, free from DST-related complications.
subtract_datetime() and add_duration()
You must convert your datetime objects to the UTC time zone before doing date math if you want to make sure that the following formulas are always true:
$dt2 - $dt1 = $dur
$dt1 + $dur = $dt2
$dt2 - $dur = $dt1
Note that using delta_days
ensures that this formula always works, regardless of the timezone of the objects involved, as does using subtract_datetime_absolute()
. Other methods of subtraction are not always reversible.
The parts of a duration can be broken down into five parts. These are months, days, minutes, seconds, and nanoseconds. Adding one month to a date is different than adding 4 weeks or 28, 29, 30, or 31 days. Similarly, due to DST and leap seconds, adding a day can be different than adding 86,400 seconds, and adding a minute is not exactly the same as 60 seconds.
We cannot convert between these units, except for seconds and nanoseconds, because there is no fixed conversion between the two units, because of things like leap seconds, DST changes, etc.
DateTime.pm
always adds (or subtracts) days, then months, minutes, and then seconds and nanoseconds. If there are any boundary overflows, these are normalized at each step. For the days and months the local (not UTC) values are used. For minutes and seconds, the local values are used. This generally just works.
This means that adding one month and one day to February 28, 2003 will produce the date April 1, 2003, not March 29, 2003.
my $dt = DateTime->new( year => 2003, month => 2, day => 28 );
$dt->add( months => 1, days => 1 );
# 2003-04-01 - the result
On the other hand, if we add months first, and then separately add days, we end up with March 29, 2003:
$dt->add( months => 1 )->add( days => 1 );
# 2003-03-29
We see similar strangeness when math crosses a DST boundary:
my $dt = DateTime->new(
year => 2003,
month => 4,
day => 5,
hour => 1,
minute => 58,
time_zone => "America/Chicago",
);
$dt->add( days => 1, minutes => 3 );
# 2003-04-06 02:01:00
$dt->add( minutes => 3 )->add( days => 1 );
# 2003-04-06 03:01:00
Note that if you converted the datetime object to UTC first you would get predictable results.
If you want to know how many seconds a duration object represents, you have to add it to a datetime to find out, so you could do:
my $now = DateTime->now( time_zone => 'UTC' );
my $later = $now->clone->add_duration($duration);
my $seconds_dur = $later->subtract_datetime_absolute($now);
This returns a duration which only contains seconds and nanoseconds.
If we were add the duration to a different datetime object we might get a different number of seconds.
DateTime::Duration supports three different end-of-month algorithms for adding months. This comes into play when an addition results in a day past the end of the month (for example, adding one month to January 30).
# 2010-08-31 + 1 month = 2010-10-01
$dt->add( months => 1, end_of_month => 'wrap' );
# 2010-01-30 + 1 month = 2010-02-28
$dt->add( months => 1, end_of_month => 'limit' );
# 2010-04-30 + 1 month = 2010-05-31
$dt->add( months => 1, end_of_month => 'preserve' );
By default, it uses "wrap" for positive durations and "preserve" for negative durations. See DateTime::Duration for a detailed explanation of these algorithms.
If you need to do lots of work with durations, take a look at Rick Measham's DateTime::Format::Duration
module, which lets you present information from durations in many useful ways.
There are other subtract/delta methods in DateTime.pm to generate different types of durations. These methods are subtract_datetime()
, subtract_datetime_absolute()
, delta_md()
, delta_days()
, and delta_ms()
.
Date subtraction is done solely based on the two object's local datetimes, with one exception to handle DST changes. Also, if the two datetime objects are in different time zones, one of them is converted to the other's time zone first before subtraction. This is best explained through examples:
The first of these probably makes the most sense:
my $dt1 = DateTime->new(
year => 2003,
month => 5,
day => 6,
time_zone => 'America/Chicago',
);
# not DST
my $dt2 = DateTime->new(
year => 2003,
month => 11,
day => 6,
time_zone => 'America/Chicago',
);
# is DST
my $dur = $dt2->subtract_datetime($dt1);
# 6 months
Nice and simple.
This one is a little trickier, but still fairly logical:
my $dt1 = DateTime->new(
year => 2003,
month => 4,
day => 5,
hour => 1,
minute => 58,
time_zone => "America/Chicago",
);
# is DST
my $dt2 = DateTime->new(
year => 2003,
month => 4,
day => 7,
hour => 2,
minute => 1,
time_zone => "America/Chicago",
);
# not DST
my $dur = $dt2->subtract_datetime($dt1);
# 2 days and 3 minutes
Which contradicts the result this one gives, even though they both make sense:
my $dt1 = DateTime->new(
year => 2003,
month => 4,
day => 5,
hour => 1,
minute => 58,
time_zone => "America/Chicago",
);
# is DST
my $dt2 = DateTime->new(
year => 2003,
month => 4,
day => 6,
hour => 3,
minute => 1,
time_zone => "America/Chicago",
);
# not DST
my $dur = $dt2->subtract_datetime($dt1);
# 1 day and 3 minutes
This last example illustrates the "DST" exception mentioned earlier. The exception accounts for the fact 2003-04-06 only lasts 23 hours.
And finally:
my $dt2 = DateTime->new(
year => 2003,
month => 10,
day => 26,
hour => 1,
time_zone => 'America/Chicago',
);
my $dt1 = $dt2->clone->subtract( hours => 1 );
my $dur = $dt2->subtract_datetime($dt1);
# 60 minutes
This seems obvious until you realize that subtracting 60 minutes from $dt2
in the above example still leaves the clock time at "01:00:00". This time we are accounting for a 25 hour day.
Date math operations are not always reversible. This is because of the way that addition operations are ordered. As was discussed earlier, adding 1 day and 3 minutes in one call to add()
is not the same as first adding 3 minutes and 1 day in two separate calls.
If we take a duration returned from subtract_datetime()
and then try to add or subtract that duration from one of the datetimes we just used, we sometimes get interesting results:
my $dt1 = DateTime->new(
year => 2003,
month => 4,
day => 5,
hour => 1,
minute => 58,
time_zone => "America/Chicago",
);
my $dt2 = DateTime->new(
year => 2003,
month => 4,
day => 6,
hour => 3,
minute => 1,
time_zone => "America/Chicago",
);
my $dur = $dt2->subtract_datetime($dt1);
# 1 day and 3 minutes
$dt1->add_duration($dur);
# gives us $dt2
$dt2->subtract_duration($dur);
# gives us 2003-04-05 02:58:00 - 1 hour later than $dt1
The subtract_duration()
operation gives us a (perhaps) unexpected answer because it first subtracts one day to get 2003-04-05T03:01:00 and then subtracts 3 minutes to get the final result.
If we explicitly reverse the order we can get the original value of $dt1
. This can be facilitated by DateTime::Duration
's calendar_duration()
and clock_duration()
methods:
$dt2->subtract_duration( $dur->clock_duration )
->subtract_duration( $dur->calendar_duration );
The presence of leap seconds can cause even more anomalies in date math. For example, the following is a legal datetime:
my $dt = DateTime->new(
year => 1972,
month => 12,
day => 31,
hour => 23,
minute => 59,
second => 60,
time_zone => 'UTC'
);
If we do the following:
$dt->add( months => 1 );
Then the datetime is now "1973-02-01 00:00:00", because there is no 23:59:60 on 1973-01-31.
Leap seconds also force us to distinguish between minutes and seconds during date math. Given the following datetime:
my $dt = DateTime->new(
year => 1972,
month => 12,
day => 31,
hour => 23,
minute => 59,
second => 30,
time_zone => 'UTC'
);
we will get different results when adding 1 minute than we get if we add 60 seconds. This is because in this case, the last minute of the day, beginning at 23:59:00, actually contains 61 seconds.
Here are the results we get:
# 1972-12-31 23:59:30 - our starting datetime
$dt->clone->add( minutes => 1 );
# 1973-01-01 00:00:30 - one minute later
$dt->clone->add( seconds => 60 );
# 1973-01-01 00:00:29 - 60 seconds later
$dt->clone->add( seconds => 61 );
# 1973-01-01 00:00:30 - 61 seconds later
When math crosses a daylight saving boundary, a single day may have more or less than 24 hours.
For example, if you do this:
my $dt = DateTime->new(
year => 2003,
month => 4,
day => 5,
hour => 2,
time_zone => 'America/Chicago',
);
$dt->add( days => 1 );
then you will produce an invalid local time, and therefore an exception will be thrown.
However, this works:
my $dt = DateTime->new(
year => 2003,
month => 4,
day => 5,
hour => 2,
time_zone => 'America/Chicago',
);
$dt->add( hours => 24 );
and produces a datetime with the local time of "03:00".
If all this makes your head hurt, there is a simple alternative. Just convert your datetime object to the "UTC" time zone before doing date math on it, and switch it back to the local time zone afterwards. This avoids the possibility of having date math throw an exception, and makes sure that 1 day equals 24 hours. Of course, this may not always be desirable, so caveat user!
This module explicitly overloads the addition (+), subtraction (-), string and numeric comparison operators. This means that the following all do sensible things:
my $new_dt = $dt + $duration_obj;
my $new_dt = $dt - $duration_obj;
my $duration_obj = $dt - $new_dt;
foreach my $dt ( sort @dts ) { ... }
Additionally, the fallback parameter is set to true, so other derivable operators (+=, -=, etc.) will work properly. Do not expect increment (++) or decrement (--) to do anything useful.
The string comparison operators, eq
or ne
, will use the string value to compare with non-DateTime objects.
DateTime objects do not have a numeric value, using ==
or <=>
to compare a DateTime object with a non-DateTime object will result in an exception. To safely sort mixed DateTime and non-DateTime objects, use sort { $a cmp $b } @dates
.
The module also overloads stringification using the object's formatter, defaulting to iso8601()
method. See "Formatters And Stringification" for details.
You can optionally specify a "formatter", which is usually a DateTime::Format::* object/class, to control the stringification of the DateTime object.
Any of the constructor methods can accept a formatter argument:
my $formatter = DateTime::Format::Strptime->new(...);
my $dt = DateTime->new(year => 2004, formatter => $formatter);
Or, you can set it afterwards:
$dt->set_formatter($formatter);
$formatter = $dt->formatter();
Once you set the formatter, the overloaded stringification method will use the formatter. If unspecified, the iso8601()
method is used.
A formatter can be handy when you know that in your application you want to stringify your DateTime objects into a special format all the time, for example to a different language.
If you provide a formatter class name or object, it must implement a format_datetime
method. This method will be called with just the DateTime object as its argument.
The CLDR pattern language is both more powerful and more complex than strftime. Unlike strftime patterns, you often have to explicitly escape text that you do not want formatted, as the patterns are simply letters without any prefix.
For example, "yyyy-MM-dd" is a valid CLDR pattern. If you want to include any lower or upper case ASCII characters as-is, you can surround them with single quotes ('). If you want to include a single quote, you must escape it as two single quotes ('').
'Today is ' EEEE
'It is now' h 'o''clock' a
Spaces and any non-letter text will always be passed through as-is.
Many CLDR patterns which produce numbers will pad the number with leading zeroes depending on the length of the format specifier. For example, "h" represents the current hour from 1-12. If you specify "hh" then the 1-9 will have a leading zero prepended.
However, CLDR often uses five of a letter to represent the narrow form of a pattern. This inconsistency is necessary for backwards compatibility.
CLDR often distinguishes between the "format" and "stand-alone" forms of a pattern. The format pattern is used when the thing in question is being placed into a larger string. The stand-alone form is used when displaying that item by itself, for example in a calendar.
It also often provides three sizes for each item, wide (the full name), abbreviated, and narrow. The narrow form is often just a single character, for example "T" for "Tuesday", and may not be unique.
CLDR provides a fairly complex system for localizing time zones that we ignore entirely. The time zone patterns just use the information provided by DateTime::TimeZone
, and do not follow the CLDR spec.
The output of a CLDR pattern is always localized, when applicable.
CLDR provides the following patterns:
G{1,3}
The abbreviated era (BC, AD).
GGGG
The wide era (Before Christ, Anno Domini).
GGGGG
The narrow era, if it exists (and it mostly doesn't).
y and y{3,}
The year, zero-prefixed as needed. Negative years will start with a "-", and this will be included in the length calculation.
In other, words the "yyyyy" pattern will format year -1234 as "-1234", not "-01234".
yy
This is a special case. It always produces a two-digit year, so "1976" becomes "76". Negative years will start with a "-", making them one character longer.
Y{1,}
The week of the year, from $dt->week_year()
.
u{1,}
Same as "y" except that "uu" is not a special case.
Q{1,2}
The quarter as a number (1..4).
QQQ
The abbreviated format form for the quarter.
QQQQ
The wide format form for the quarter.
q{1,2}
The quarter as a number (1..4).
qqq
The abbreviated stand-alone form for the quarter.
qqqq
The wide stand-alone form for the quarter.
M{1,2]
The numerical month.
MMM
The abbreviated format form for the month.
MMMM
The wide format form for the month.
MMMMM
The narrow format form for the month.
L{1,2]
The numerical month.
LLL
The abbreviated stand-alone form for the month.
LLLL
The wide stand-alone form for the month.
LLLLL
The narrow stand-alone form for the month.
w{1,2}
The week of the year, from $dt->week_number()
.
W
The week of the month, from $dt->week_of_month()
.
d{1,2}
The numeric day of the month.
D{1,3}
The numeric day of the year.
F
The day of the week in the month, from $dt->weekday_of_month()
.
g{1,}
The modified Julian day, from $dt->mjd()
.
E{1,3} and eee
The abbreviated format form for the day of the week.
EEEE and eeee
The wide format form for the day of the week.
EEEEE and eeeee
The narrow format form for the day of the week.
e{1,2}
The local numeric day of the week, from 1 to 7. This number depends on what day is considered the first day of the week, which varies by locale. For example, in the US, Sunday is the first day of the week, so this returns 2 for Monday.
c
The numeric day of the week from 1 to 7, treating Monday as the first of the week, regardless of locale.
ccc
The abbreviated stand-alone form for the day of the week.
cccc
The wide stand-alone form for the day of the week.
ccccc
The narrow format form for the day of the week.
a
The localized form of AM or PM for the time.
h{1,2}
The hour from 1-12.
H{1,2}
The hour from 0-23.
K{1,2}
The hour from 0-11.
k{1,2}
The hour from 1-24.
j{1,2}
The hour, in 12 or 24 hour form, based on the preferred form for the locale. In other words, this is equivalent to either "h{1,2}" or "H{1,2}".
m{1,2}
The minute.
s{1,2}
The second.
S{1,}
The fractional portion of the seconds, rounded based on the length of the specifier. This returned without a leading decimal point, but may have leading or trailing zeroes.
A{1,}
The millisecond of the day, based on the current time. In other words, if it is 12:00:00.00, this returns 43200000.
z{1,3}
The time zone short name.
zzzz
The time zone long name.
Z{1,3}
The time zone offset.
ZZZZ
The time zone short name and the offset as one string, so something like "CDT-0500".
ZZZZZ
The time zone offset as a sexagesimal number, so something like "-05:00". (This is useful for W3C format.)
v{1,3}
The time zone short name.
vvvv
The time zone long name.
V{1,3}
The time zone short name.
VVVV
The time zone long name.
The following patterns are allowed in the format string given to the $dt->strftime()
method:
%a
The abbreviated weekday name.
%A
The full weekday name.
%b
The abbreviated month name.
%B
The full month name.
%c
The default datetime format for the object's locale.
%C
The century number (year/100) as a 2-digit integer.
%d
The day of the month as a decimal number (range 01 to 31).
%D
Equivalent to %m/%d/%y. This is not a good standard format if you want folks from both the United States and the rest of the world to understand the date!
%e
Like %d, the day of the month as a decimal number, but a leading zero is replaced by a space.
%F
Equivalent to %Y-%m-%d (the ISO 8601 date format)
%G
The ISO 8601 year with century as a decimal number. The 4-digit year corresponding to the ISO week number (see %V). This has the same format and value as %Y, except that if the ISO week number belongs to the previous or next year, that year is used instead. (TZ)
%g
Like %G, but without century, i.e., with a 2-digit year (00-99).
%h
Equivalent to %b.
%H
The hour as a decimal number using a 24-hour clock (range 00 to 23).
%I
The hour as a decimal number using a 12-hour clock (range 01 to 12).
%j
The day of the year as a decimal number (range 001 to 366).
%k
The hour (24-hour clock) as a decimal number (range 0 to 23); single digits are preceded by a blank. (See also %H.)
%l
The hour (12-hour clock) as a decimal number (range 1 to 12); single digits are preceded by a blank. (See also %I.)
%m
The month as a decimal number (range 01 to 12).
%M
The minute as a decimal number (range 00 to 59).
%n
A newline character.
%N
The fractional seconds digits. Default is 9 digits (nanoseconds).
%3N milliseconds (3 digits)
%6N microseconds (6 digits)
%9N nanoseconds (9 digits)
This value will always be rounded down to the nearest integer.
%p
Either `AM' or `PM' according to the given time value, or the corresponding strings for the current locale. Noon is treated as `pm' and midnight as `am'.
%P
Like %p but in lowercase: `am' or `pm' or a corresponding string for the current locale.
%r
The time in a.m. or p.m. notation. In the POSIX locale this is equivalent to `%I:%M:%S %p'.
%R
The time in 24-hour notation (%H:%M). (SU) For a version including the seconds, see %T below.
%s
The number of seconds since the epoch.
%S
The second as a decimal number (range 00 to 61).
%t
A tab character.
%T
The time in 24-hour notation (%H:%M:%S).
%u
The day of the week as a decimal, range 1 to 7, Monday being 1. See also %w.
%U
The week number of the current year as a decimal number, range 00 to 53, starting with the first Sunday as the first day of week 01. See also %V and %W.
%V
The ISO 8601:1988 week number of the current year as a decimal number, range 01 to 53, where week 1 is the first week that has at least 4 days in the current year, and with Monday as the first day of the week. See also %U and %W.
%w
The day of the week as a decimal, range 0 to 6, Sunday being 0. See also %u.
%W
The week number of the current year as a decimal number, range 00 to 53, starting with the first Monday as the first day of week 01.
%x
The default date format for the object's locale.
%X
The default time format for the object's locale.
%y
The year as a decimal number without a century (range 00 to 99).
%Y
The year as a decimal number including the century.
%z
The time-zone as hour offset from UTC. Required to emit RFC822-conformant dates (using "%a, %d %b %Y %H:%M:%S %z").
%Z
The time zone or name or abbreviation.
%%
A literal `%' character.
%{method}
Any method name may be specified using the format %{method}
name where "method" is a valid DateTime.pm
object method.
DateTime implements Storable hooks in order to reduce the size of a serialized DateTime object.
This module is part of a larger ecosystem of modules in the DateTime family.
The DateTime::Set module represents sets (including recurrences) of datetimes. Many modules return sets or recurrences.
The various format modules exist to parse and format datetimes. For example, DateTime::Format::HTTP parses dates according to the RFC 1123 format:
my $datetime
= DateTime::Format::HTTP->parse_datetime('Thu Feb 3 17:03:55 GMT 1994');
print DateTime::Format::HTTP->format_datetime($datetime);
Most format modules are suitable for use as a formatter
with a DateTime object.
All format modules start with DateTime::Format::
.
There are a number of modules on CPAN that implement non-Gregorian calendars, such as the Chinese, Mayan, and Julian calendars.
All calendar modules start with DateTime::Calendar::
.
There are a number of modules that calculate the dates for events, such as Easter, Sunrise, etc.
All event modules start with DateTime::Event::
.
There are many other modules that work with DateTime, including modules in the DateTimeX
namespace, as well as others.
See the datetime wiki and search.cpan.org for more details.
The tests in 20infinite.t seem to fail on some machines, particularly on Win32. This appears to be related to Perl's internal handling of IEEE infinity and NaN, and seems to be highly platform/compiler/phase of moon dependent.
If you don't plan to use infinite datetimes you can probably ignore this. This will be fixed (perhaps) in future versions.
Support for this module is provided via the<EMAIL_ADDRESS>email list. See http://datetime.perl.org/wiki/datetime/page/Mailing_List for details.
Please submit bugs to the CPAN RT system at http://rt.cpan.org/NoAuth/Bugs.html?Dist=DateTime or via email at<EMAIL_ADDRESS>If you'd like to thank me for the work I've done on this module, please consider making a "donation" to me via PayPal. I spend a lot of free time creating free software, and would appreciate any support you'd care to offer.
Please note that I am not suggesting that you must do this in order for me to continue working on this particular software. I will continue to do so, inasmuch as I have in the past, for as long as it interests me.
Similarly, a donation made in this way will probably not make me work on this software much more, unless I get so many donations that I can consider working on free software full time, which seems unlikely at best.
To donate, log into PayPal and send money to<EMAIL_ADDRESS>or use the button on this page: http://www.urth.org/~autarch/fs-donation.html
A Date with Perl - a talk I've given at a few YAPCs.
<EMAIL_ADDRESS>mailing list
Dave Rolsky<EMAIL_ADDRESS>Ben Bennett<EMAIL_ADDRESS>Christian Hansen<EMAIL_ADDRESS>Daisuke Maki<EMAIL_ADDRESS>David E. Wheeler<EMAIL_ADDRESS>Doug Bell<EMAIL_ADDRESS>Flávio Soibelmann Glock<EMAIL_ADDRESS>Iain Truskett <deceased>
Joshua Hoblitt<EMAIL_ADDRESS>Ricardo Signes<EMAIL_ADDRESS>Richard Bowen<EMAIL_ADDRESS>Ron Hill<EMAIL_ADDRESS>This software is Copyright (c) 2015 by Dave Rolsky.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)


@* * Copyright 2023 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *@ @import includes.cancelLink @import uk.gov.hmrc.govukfrontend.views.html.components._ @import uk.gov.hmrc.tai.forms.YesNoForm @this(mainTemplate: MainTemplate, duplicateSubmissionWarning: includes.duplicateSubmissionWarning, govukRadios: GovukRadios, govukErrorSummary: GovukErrorSummary) @(duplicateSubmissionWarningForm: Form[YesNoForm], pensionName: String, pensionId: Int)(implicit request: Request[_], messages: Messages, user: controllers.auth.AuthedUser) @mainTemplate( title = messages("tai.pension.warning.customGaTitle"), authedUser = Some(user), backLinkId = "backLink", backLinkContent = Some(Messages("tai.back-link.upper")), backLinkUrl = Some(controllers.routes.IncomeSourceSummaryController.onPageLoad(pensionId).url), formForErrorSummary = Some(duplicateSubmissionWarningForm) ){


Drascombe/Devon Boats
from £75/day
Ready about! This is sailing, the Dras-go way.
Choose your boat, tell us where and when you want to sail, and we'll deliver to your chosen inland sailing ground (England only). We'll also show you how everything works and launch for you, if required.
No faff, no hassle, just quality sailing time without the cost of ownership.
Choose from our beautiful fleet of Drascombe/Devon boats. We have:
- Drascombe Coaster
- Devon Lugger
- Devon Scaffie
Prices:
Scaffie
- £75/day
- £325/week
Lugger
- £95/day
- £425/week
Coaster
- £150/day
- £500/week
Note: We require evidence of at least RYA Dayskipper theory and practical certificates or above (an ICC certificate is adequate) to charter any of our boats.


Salary Calculator
Add Employee
Submit
First Name
Last Name
ID
Title
Annual Salary
Delete Item
Monthly Salary : $0


Launching satellites into space could soon be easier and cheaper than ever before, thanks to research at The University of Queensland.
Launching satellites into space could soon be easier and cheaper than ever before, thanks to research at The University of Queensland.


Class ListBase<T>
ListBase is an abstract class that can be used as a base class for a read-write collection that needs to implement the generic IList<T> and non-generic IList collections. The derived class needs to override the following methods: Count, Clear, Insert, RemoveAt, and the indexer. The implementation of all the other methods in IList<T> and IList are handled by ListBase.
Implements
Inherited Members
Namespace: Wintellect.PowerCollections
Assembly: CADability.dll
Syntax
[Serializable]
public abstract class ListBase<T> : CollectionBase<T>, IList<T>, ICollection<T>, IEnumerable<T>, IList, ICollection, IEnumerable
Type Parameters
| Name | Description |
|---|---|
| T |
Constructors
| Improve this Doc View SourceListBase()
Creates a new ListBase.
Declaration
protected ListBase()
Properties
| Improve this Doc View SourceCount
The property must be overridden by the derived class to return the number of items in the list.
Declaration
public abstract override int Count { get; }
Property Value
| Type | Description |
|---|---|
| System.Int32 | The number of items in the list. |
Overrides
Item[Int32]
The indexer must be overridden by the derived class to get and set values of the list at a particular index.
Declaration
public abstract T this[int index] { get; set; }
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | index | The index in the list to get or set an item at. The first item in the list has index 0, and the last has index Count-1. |
Property Value
| Type | Description |
|---|---|
| T | The item at the given index. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentOutOfRangeException |
|
Methods
| Improve this Doc View SourceAdd(T)
Adds an item to the end of the list. This method is equivalent to calling:
Insert(Count, item)
Declaration
public override void Add(T item)
Parameters
| Type | Name | Description |
|---|---|---|
| T | item | The item to add to the list. |
Overrides
AsReadOnly()
Provides a read-only view of this list. The returned IList<T> provides a view of the list that prevents modifications to the list. Use the method to provide access to the list without allowing changes. Since the returned object is just a view, changes to the list will be reflected in the view.
Declaration
public virtual IList<T> AsReadOnly()
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.IList<T> | An IList<T> that provides read-only access to the list. |
Clear()
This method must be overridden by the derived class to empty the list of all items.
Declaration
public abstract override void Clear()
Overrides
Contains(T)
Determines if the list contains any item that compares equal to item
.
The implementation simply checks whether IndexOf(item) returns a non-negative value.
Declaration
public override bool Contains(T item)
Parameters
| Type | Name | Description |
|---|---|---|
| T | item | The item to search for. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the list contains an item that compares equal to |
Overrides
Remarks
Equality in the list is determined by the default sense of equality for T. If T implements IComparable<T>, the Equals method of that interface is used to determine equality. Otherwise, Object.Equals is used to determine equality.
CopyTo(T[])
Copies all the items in the list, in order, to array
,
starting at index 0.
Declaration
public virtual void CopyTo(T[] array)
Parameters
| Type | Name | Description |
|---|---|---|
| T[] | array | The array to copy to. This array must have a size that is greater than or equal to Count. |
CopyTo(T[], Int32)
Copies all the items in the list, in order, to array
,
starting at arrayIndex
.
Declaration
public override void CopyTo(T[] array, int arrayIndex)
Parameters
| Type | Name | Description |
|---|---|---|
| T[] | array | The array to copy to. This array must have a size that is greater than or equal to Count + arrayIndex. |
| System.Int32 | arrayIndex | The starting index in |
Overrides
CopyTo(Int32, T[], Int32, Int32)
Copies a range of elements from the list to array
,
starting at arrayIndex
.
Declaration
public virtual void CopyTo(int index, T[] array, int arrayIndex, int count)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | index | The starting index in the source list of the range to copy. |
| T[] | array | The array to copy to. This array must have a size that is greater than or equal to Count + arrayIndex. |
| System.Int32 | arrayIndex | The starting index in |
| System.Int32 | count | The number of items to copy. |
Find(Predicate<T>)
Finds the first item in the list that satisfies the condition
defined by predicate
. If no item matches the condition, than
the default value for T (null or all-zero) is returned.
Declaration
public virtual T Find(Predicate<T> predicate)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Predicate<T> | predicate | A delegate that defined the condition to check for. |
Returns
| Type | Description |
|---|---|
| T | The first item that satisfies the condition |
Remarks
If the default value for T (null or all-zero) matches the condition defined by predicate
,
and the list might contain the default value, then it is impossible to distinguish the different between finding
the default value and not finding any item. To distinguish these cases, use TryFind(Predicate<T>, out T).
See Also
| Improve this Doc View SourceFindIndex(Int32, Int32, Predicate<T>)
Finds the index of the first item, in the range of count
items starting from index
, that satisfies the condition
defined by predicate
. If no item matches the condition, -1 is returned.
Declaration
public virtual int FindIndex(int index, int count, Predicate<T> predicate)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | index | The starting index of the range to check. |
| System.Int32 | count | The number of items in range to check. |
| System.Predicate<T> | predicate | A delegate that defined the condition to check for. |
Returns
| Type | Description |
|---|---|
| System.Int32 | The index of the first item in the given range that satisfies the condition |
FindIndex(Int32, Predicate<T>)
Finds the index of the first item, in the range of items extending from index
to the end, that satisfies the condition
defined by predicate
. If no item matches the condition, -1 is returned.
Declaration
public virtual int FindIndex(int index, Predicate<T> predicate)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | index | The starting index of the range to check. |
| System.Predicate<T> | predicate | A delegate that defined the condition to check for. |
Returns
| Type | Description |
|---|---|
| System.Int32 | The index of the first item in the given range that satisfies the condition |
FindIndex(Predicate<T>)
Finds the index of the first item in the list that satisfies the condition
defined by predicate
. If no item matches the condition, -1 is returned.
Declaration
public virtual int FindIndex(Predicate<T> predicate)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Predicate<T> | predicate | A delegate that defined the condition to check for. |
Returns
| Type | Description |
|---|---|
| System.Int32 | The index of the first item that satisfies the condition |
FindLast(Predicate<T>)
Finds the last item in the list that satisfies the condition
defined by predicate
. If no item matches the condition, than
the default value for T (null or all-zero) is returned.
Declaration
public virtual T FindLast(Predicate<T> predicate)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Predicate<T> | predicate | A delegate that defined the condition to check for. |
Returns
| Type | Description |
|---|---|
| T | The last item that satisfies the condition |
Remarks
If the default value for T (null or all-zero) matches the condition defined by predicate
,
and the list might contain the default value, then it is impossible to distinguish the different between finding
the default value and not finding any item. To distinguish these cases, use TryFindLast(Predicate<T>, out T).
See Also
| Improve this Doc View SourceFindLastIndex(Int32, Int32, Predicate<T>)
Finds the index of the last item, in the range of count
items ending at index
, that satisfies the condition
defined by predicate
. If no item matches the condition, -1 is returned.
Declaration
public virtual int FindLastIndex(int index, int count, Predicate<T> predicate)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | index | The ending index of the range to check. |
| System.Int32 | count | The number of items in range to check. |
| System.Predicate<T> | predicate | A delegate that defined the condition to check for. |
Returns
| Type | Description |
|---|---|
| System.Int32 | The index of the last item in the given range that satisfies the condition |
FindLastIndex(Int32, Predicate<T>)
Finds the index of the last item, in the range of items extending from the beginning
of the list to index
, that satisfies the condition
defined by predicate
. If no item matches the condition, -1 is returned.
Declaration
public virtual int FindLastIndex(int index, Predicate<T> predicate)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | index | The ending index of the range to check. |
| System.Predicate<T> | predicate | A delegate that defined the condition to check for. |
Returns
| Type | Description |
|---|---|
| System.Int32 | The index of the last item in the given range that satisfies the condition |
FindLastIndex(Predicate<T>)
Finds the index of the last item in the list that satisfies the condition
defined by predicate
. If no item matches the condition, -1 is returned.
Declaration
public virtual int FindLastIndex(Predicate<T> predicate)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Predicate<T> | predicate | A delegate that defined the condition to check for. |
Returns
| Type | Description |
|---|---|
| System.Int32 | The index of the last item that satisfies the condition |
GetEnumerator()
Enumerates all of the items in the list, in order. The item at index 0 is enumerated first, then the item at index 1, and so on.
Declaration
public override IEnumerator<T> GetEnumerator()
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerator<T> | An IEnumerator<T> that enumerates all the items in the list. |
Overrides
Remarks
The enumerator does not check for changes made to the structure of the list. Thus, changes to the list during enumeration may cause incorrect enumeration or out of range exceptions. Consider overriding this method and adding checks for structural changes.
IndexOf(T)
Finds the index of the first item in the list that is equal to item
.
Declaration
public virtual int IndexOf(T item)
Parameters
| Type | Name | Description |
|---|---|---|
| T | item | The item to search fror. |
Returns
| Type | Description |
|---|---|
| System.Int32 | The index of the first item in the list that that is equal to |
Remarks
The default implementation of equality for type T is used in the search. This is the equality defined by IComparable<T> or object.Equals.
IndexOf(T, Int32)
Finds the index of the first item, in the range of items extending from index
to the end,
that is equal to item
.
Declaration
public virtual int IndexOf(T item, int index)
Parameters
| Type | Name | Description |
|---|---|---|
| T | item | The item to search fror. |
| System.Int32 | index | The starting index of the range to check. |
Returns
| Type | Description |
|---|---|
| System.Int32 | The index of the first item in the given range that that is equal to |
Remarks
The default implementation of equality for type T is used in the search. This is the equality defined by IComparable<T> or object.Equals.
IndexOf(T, Int32, Int32)
Finds the index of the first item, in the range of count
items starting from index
,
that is equal to item
.
Declaration
public virtual int IndexOf(T item, int index, int count)
Parameters
| Type | Name | Description |
|---|---|---|
| T | item | The item to search fror. |
| System.Int32 | index | The starting index of the range to check. |
| System.Int32 | count | The number of items in range to check. |
Returns
| Type | Description |
|---|---|
| System.Int32 | The index of the first item in the given range that that is equal to |
Remarks
The default implementation of equality for type T is used in the search. This is the equality defined by IComparable<T> or object.Equals.
Insert(Int32, T)
This method must be overridden by the derived class to insert a new item at the given index.
Declaration
public abstract void Insert(int index, T item)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | index | The index in the list to insert the item at. After the insertion, the inserted item is located at this index. The first item in the list has index 0. |
| T | item | The item to insert at the given index. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentOutOfRangeException |
|
LastIndexOf(T)
Finds the index of the last item in the list that is equal to item
.
Declaration
public virtual int LastIndexOf(T item)
Parameters
| Type | Name | Description |
|---|---|---|
| T | item | The item to search fror. |
Returns
| Type | Description |
|---|---|
| System.Int32 | The index of the last item in the list that that is equal to |
Remarks
The default implementation of equality for type T is used in the search. This is the equality defined by IComparable<T> or object.Equals.
LastIndexOf(T, Int32)
Finds the index of the last item, in the range of items extending from the beginning
of the list to index
, that is equal to item
.
Declaration
public virtual int LastIndexOf(T item, int index)
Parameters
| Type | Name | Description |
|---|---|---|
| T | item | The item to search fror. |
| System.Int32 | index | The ending index of the range to check. |
Returns
| Type | Description |
|---|---|
| System.Int32 | The index of the last item in the given range that that is equal to |
Remarks
The default implementation of equality for type T is used in the search. This is the equality defined by IComparable<T> or object.Equals.
LastIndexOf(T, Int32, Int32)
Finds the index of the last item, in the range of count
items ending at index
,
that is equal to item
.
Declaration
public virtual int LastIndexOf(T item, int index, int count)
Parameters
| Type | Name | Description |
|---|---|---|
| T | item | The item to search for. |
| System.Int32 | index | The ending index of the range to check. |
| System.Int32 | count | The number of items in range to check. |
Returns
| Type | Description |
|---|---|
| System.Int32 | The index of the last item in the given range that that is equal to |
Remarks
The default implementation of equality for type T is used in the search. This is the equality defined by IComparable<T> or object.Equals.
Range(Int32, Int32)
Returns a view onto a sub-range of this list. Items are not copied; the returned IList<T> is simply a different view onto the same underlying items. Changes to this list are reflected in the view, and vice versa. Insertions and deletions in the view change the size of the view, but insertions and deletions in the underlying list do not.
Declaration
public virtual IList<T> Range(int start, int count)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | start | The starting index of the view. |
| System.Int32 | count | The number of items in the view. |
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.IList<T> | A list that is a view onto the given sub-part of this list. |
Remarks
This method can be used to apply an algorithm to a portion of a list. For example:
Algorithms.ReverseInPlace(deque.Range(3, 6))
will reverse the 6 items beginning at index 3.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentOutOfRangeException |
|
| System.ArgumentOutOfRangeException |
|
Remove(T)
Searches the list for the first item that compares equal to item
.
If one is found, it is removed. Otherwise, the list is unchanged.
Declaration
public override bool Remove(T item)
Parameters
| Type | Name | Description |
|---|---|---|
| T | item | The item to remove from the list. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if an item was found and removed that compared equal to
|
Overrides
Remarks
Equality in the list is determined by the default sense of equality for T. If T implements IComparable<T>, the Equals method of that interface is used to determine equality. Otherwise, Object.Equals is used to determine equality.
RemoveAt(Int32)
This method must be overridden by the derived class to remove the item at the given index.
Declaration
public abstract void RemoveAt(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | index | The index in the list to remove the item at. The first item in the list has index 0. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentOutOfRangeException |
|
TryFind(Predicate<T>, out T)
Finds the first item in the list that satisfies the condition
defined by predicate
.
Declaration
public virtual bool TryFind(Predicate<T> predicate, out T foundItem)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Predicate<T> | predicate | A delegate that defines the condition to check for. |
| T | foundItem | If true is returned, this parameter receives the first item in the list
that satifies the condition defined by |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if an item that satisfies the condition |
TryFindLast(Predicate<T>, out T)
Finds the last item in the list that satisfies the condition
defined by predicate
.
Declaration
public virtual bool TryFindLast(Predicate<T> predicate, out T foundItem)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Predicate<T> | predicate | A delegate that defines the condition to check for. |
| T | foundItem | If true is returned, this parameter receives the last item in the list
that satifies the condition defined by |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if an item that satisfies the condition |
Explicit Interface Implementations
| Improve this Doc View SourceIList.Add(Object)
Adds an item to the end of the list. This method is equivalent to calling:
Insert(Count, item)
Declaration
int IList.Add(object value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | value | The item to add to the list. |
Returns
| Type | Description |
|---|---|
| System.Int32 |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException |
|
IList.Clear()
Removes all the items from the list, resulting in an empty list.
Declaration
void IList.Clear()
IList.Contains(Object)
Determines if the list contains any item that compares equal to value
.
Declaration
bool IList.Contains(object value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | value | The item to search for. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
Remarks
Equality in the list is determined by the default sense of equality for T. If T implements IComparable<T>, the Equals method of that interface is used to determine equality. Otherwise, Object.Equals is used to determine equality.
IList.IndexOf(Object)
Find the first occurrence of an item equal to value
in the list, and returns the index of that item.
Declaration
int IList.IndexOf(object value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | value | The item to search for. |
Returns
| Type | Description |
|---|---|
| System.Int32 | The index of |
Remarks
Equality in the list is determined by the default sense of equality for T. If T implements IComparable<T>, the Equals method of that interface is used to determine equality. Otherwise, Object.Equals is used to determine equality.
IList.Insert(Int32, Object)
Insert a new item at the given index.
Declaration
void IList.Insert(int index, object value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | index | The index in the list to insert the item at. After the insertion, the inserted item is located at this index. The first item in the list has index 0. |
| System.Object | value | The item to insert at the given index. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentOutOfRangeException |
|
| System.ArgumentException |
|
IList.IsFixedSize
Returns whether the list is a fixed size. This implementation always returns false.
Declaration
bool IList.IsFixedSize { get; }
Returns
| Type | Description |
|---|---|
| System.Boolean | Alway false, indicating that the list is not fixed size. |
IList.IsReadOnly
Returns whether the list is read only. This implementation returns the value from ICollection<T>.IsReadOnly, which is by default, false.
Declaration
bool IList.IsReadOnly { get; }
Returns
| Type | Description |
|---|---|
| System.Boolean | By default, false, indicating that the list is not read only. |
IList.Item[Int32]
Gets or sets the value at a particular index in the list.
Declaration
object IList.this[int index] { get; set; }
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | index | The index in the list to get or set an item at. The first item in the list has index 0, and the last has index Count-1. |
Returns
| Type | Description |
|---|---|
| System.Object | The item at the given index. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentOutOfRangeException |
|
| System.ArgumentException |
|
IList.Remove(Object)
Searches the list for the first item that compares equal to value
.
If one is found, it is removed. Otherwise, the list is unchanged.
Declaration
void IList.Remove(object value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | value | The item to remove from the list. |
Remarks
Equality in the list is determined by the default sense of equality for T. If T implements IComparable<T>, the Equals method of that interface is used to determine equality. Otherwise, Object.Equals is used to determine equality.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException |
|
IList.RemoveAt(Int32)
Removes the item at the given index.
Declaration
void IList.RemoveAt(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | index | The index in the list to remove the item at. The first item in the list has index 0. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentOutOfRangeException |
|


https://www.packetlevel.ch/html/scapy/docs/scapy_sans.pdf
This is how interactive scapy may be used to send a TCP SYN segment to two destination hosts, <IP_ADDRESS> and <IP_ADDRESS>, to four different destination ports – 111, 139, 445, and 80.
>>> sr(IP(dst=[“<IP_ADDRESS>”, “<IP_ADDRESS>”])/TCP(dport = [111, 139, 445, 80], flags=”S”))
Here is how interactive scapy may be used to craft a UDP datagram to send to destination host <IP_ADDRESS> and destination port 13 with some payload and listen for the response.
>>> ip=IP(dst=”<IP_ADDRESS>”)
>>> udp=UDP(sport=1024,dport=13)
>>> payload=”All your base are belong to us”
>>> packet=ip/udp/payload
>>> sr1(packet)
The following is a simple scapy program that creates an actual TCP session from source host <IP_ADDRESS> and source port 1030 to destination host <IP_ADDRESS> and destination port 80. It crafts the SYN segment, listens for the server’s SYN/ACK and acknowledges it to complete the three-way handshake. Next, it sends a segment that contains data. There is an issue with an undesirable side effect that creates a reset and inadvertently aborts the session.
#!/usr/bin/python
from scapy.all import *
ip=IP(src=”<IP_ADDRESS>”, dst=”<IP_ADDRESS>”)
SYN=TCP(sport=1030, dport=80, flags=”S”, seq=10)
SYNACK=sr1(ip/SYN)my_ack = SYNACK.seq + 1
ACK=TCP(sport=1030, dport=80, flags=”A”, seq=11, ack=my_ack)
send(ip/ACK)
payload = “SEND TCP”
PUSH=TCP(sport=1030,dport=80, flags=”PA”, seq=11, ack=my_ack)
send(ip/PUSH/payload)


Re-register for notifications
Show notifications
Show notification content
Keep notifications until manually dismissed
Display options bar
Save


The election schedule will be worked out keeping in view the logistics, weather, school calendar, security and pandemic status and with all related law and order authorities, health officials, national, state and district-level agencies. Necessary suggestions of political parties are taken into consideration. All the
The election schedule will be worked out keeping in view the logistics, weather, school calendar, security and pandemic status and with all related law and order authorities, health officials, national, state and district-level agencies. Necessary suggestions of political parties are taken into consideration. All the
The election schedule will be worked out keeping in view the logistics, weather, school calendar, security and pandemic status and with all related law and order authorities, health officials, national, state and district-level agencies. Necessary suggestions of political parties are taken into consideration. All the


Details ABOUT MODEL Details ABOUT MODEL Details ABOUT MODEL Details ABOUT MODELDetails ABOUT MODELDetails ABOUT MODELDetails ABOUT MODELDetails ABOUT MODELDetails ABOUT MODELDetails ABOUT MODELDetails ABOUT MODELDetails ABOUT MODELDetails ABOUT MODELDetails ABOUT MODELDetails ABOUT MODELDetails ABOUT MODEL
Details ABOUT MODEL Details ABOUT MODEL Details ABOUT MODEL Details ABOUT MODELDetails ABOUT MODELDetails ABOUT MODELDetails ABOUT MODELDetails ABOUT MODELDetails ABOUT MODELDetails ABOUT MODELDetails ABOUT MODELDetails ABOUT MODELDetails ABOUT MODELDetails ABOUT MODELDetails ABOUT MODELDetails ABOUT MODEL
Details ABOUT MODEL Details ABOUT MODEL Details ABOUT MODEL Details ABOUT MODELDetails ABOUT MODELDetails ABOUT MODELDetails ABOUT MODELDetails ABOUT MODELDetails ABOUT MODELDetails ABOUT MODELDetails ABOUT MODELDetails ABOUT MODELDetails ABOUT MODELDetails ABOUT MODELDetails ABOUT MODELDetails ABOUT MODEL
Details ABOUT MODEL Details ABOUT MODEL Details ABOUT MODEL Details ABOUT MODELDetails ABOUT MODELDetails ABOUT MODELDetails ABOUT MODELDetails ABOUT MODELDetails ABOUT MODELDetails ABOUT MODELDetails ABOUT MODELDetails ABOUT MODELDetails ABOUT MODELDetails ABOUT MODELDetails ABOUT MODELDetails ABOUT MODEL
- Greatest properly off ham exercise all.
- Unsatiable invitation its possession nor off.
- All difficulty estimating unreserved increasing the solicitude.
Unpleasant astonished an diminution up partiality. Noisy an their of meant. Death means up civil do an offer wound of.


Quest
Are you up for the nobel quest to save the people
Enter Player 1 Name
Enter Player 2 Name
Start


I created this simple contact forum for myself as a template. Feel free to use it if you'd like.
get in touch...
Facebook page
Stewart ilondanga
Twitter
@stew_ilondanga
Email
<EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS>Instagram
@stew_ilondanga
Created by Stewart ilondanga


NCover FAQ
If you have questions that this document does not address, contact Peter Waldschmidt.
1. What is code coverage analysis?
A code coverage analyzer monitors your code at runtime and records information about which lines of code were executed. NCover shows each sequence point in your application along with the number of times that point was executed. Sequence points are generated by the compiler and stored in the debug information (.pdb) files. A sequence point basically corresponds to a single program statement (often a line of code) in your high-level language.
2. Why would I want to do code coverage analysis?
Unit test suites are often used as a quality tool during the development process to keep the codebase stable as it changes and expands. Tools such as NUnit are often used to run and report on the test suites. However, when implementing unit testing in your build process, you have no way of knowing how much of your code the unit tests are actually testing. This is where code coverage comes in. You can run NUnit within NCover and use the code coverage report to determine which code was not tested by that particular test suite.
3. What versions of the CLR does NCover support?
At this time, NCover has only been tested on the .NET framework version 1.1.4322.
4. What is the command line syntax for NCover?
Here is the usage info from the NCover command line:
Usage: NCover /c <command line> [/a <assembly list>] /c Command line to launch profiled application. /a List of assemblies to profile. i.e. "MyAssembly1;MyAssembly2" /v Enable verbose logging (show instrumented code)
5. Does NCover required a special compilation step for my code?
No. Some code coverage tools change your source code and force you to recompile it into a special build. NCover is designed to work on shipping code. NCover uses the .NET Framework profiling API to monitor your code. It does require build symbols, but can be run on release code without any modifications.
6. How does NCover work?
NCover uses the .NET Framework profiler API to monitor an application's execution. When a method is loaded by the CLR, NCover retrieves the IL and replaces it with instrumented IL code. NCover does not change your original IL code, it simply inserts new code to update a visit counter at each sequence point. After the .NET process shuts down, the profiler outputs statistics to a file in the current directory.
7. How do I analyze an ASP.NET application with NCover?
xmspc got this to work on ASP.NET. See his post on the message board for more information. Here are the basics for getting it to work on Windows XP.
1) Ensure the NCoverLib COM component is registered (setup does this, but you can manually register it with regsvr32 if you wish).
2) Set the machine-wide COR profiling environment variables (or find some other
way to get them set in the aspnet_wp.exe's environment):
COR_ENABLE_PROFILING=1
COR_PROFILER=CvrLib.CoverageProfiler
3) Create %windir%\System32\Coverage.log and %windir%\System32\Coverage.xml and grant .\ASPNET read+write+modify permission to these 2 files only.
4) Force a restart of IIS so aspnet_wp.exe picks up the new environment variables. Coverage info will be written to the System32 directory.
All ASP.Net processes (on Windows XP for sure, don't know about Windows 2003) use %windir%\System32 as their working dir, therefore if multiple processes are running they will stomp over the Coverage files.
...would be nice if NCover used AppDomain basedir and/or value from app config file to set output file dir...
8. What is the output of NCover?
NCover writes three files to the directory after analysis completes.
<method class="NCoverTest.ClassLoaded" name="HasDeadCode"> <seqpnt document="C:\Dev\Utilities\ncover\NCoverTest\NCoverTest.cs" column="13" line="48" endcolumn="58" endline="48" visitcount="1" /> <seqpnt document="C:\Dev\Utilities\ncover\NCoverTest\NCoverTest.cs" column="13" line="49" endcolumn="22" endline="49" visitcount="1" /> <seqpnt document="C:\Dev\Utilities\ncover\NCoverTest\NCoverTest.cs" column="17" line="50" endcolumn="24" endline="50" visitcount="1" /> <seqpnt document="C:\Dev\Utilities\ncover\NCoverTest\NCoverTest.cs" column="13" line="51" endcolumn="48" endline="51" visitcount="0" /> <seqpnt document="C:\Dev\Utilities\ncover\NCoverTest\NCoverTest.cs" column="9" line="52" endcolumn="10" endline="52" visitcount="0" /> </method>
| Visit Count | Line | Column | End Line | End Column | Document |
| 1 | 48 | 13 | 48 | 58 | C:\Dev\Utilities\ncover\NCoverTest\NCoverTest.cs |
| 1 | 49 | 13 | 49 | 22 | C:\Dev\Utilities\ncover\NCoverTest\NCoverTest.cs |
| 1 | 50 | 17 | 50 | 24 | C:\Dev\Utilities\ncover\NCoverTest\NCoverTest.cs |
| 0 | 51 | 13 | 51 | 48 | C:\Dev\Utilities\ncover\NCoverTest\NCoverTest.cs |
| 0 | 52 | 9 | 52 | 10 | C:\Dev\Utilities\ncover\NCoverTest\NCoverTest.cs |
9. How do you test NCover?
Unfortunately, all the original testing was done with production code that cannot be published. I have started on a test suite called NCoverTest. It is pretty anemic right now, but feel free to chip in and contribute some tests.


Prolog can get or modify the contents of a foreign term with the procedures
get_contents(+Datum, ?Part, ?Value) put_contents(+Datum, +Part, +Value).
It can also get a pointer to a field or element of a foreign term with the procedure
get_address(+Datum, ?Part, ?Value).
For all three of these, Datum must be a foreign term, and
Part specifies what part of Datum Value is. If
Datum is an array, Part should be an integer index into
the array, where 0 is the first element. For a pointer, Part
should be the atom contents
and Value will be what the pointer
points to. For a struct, Part should be a field name, and
Value will be the contents of that field. In the case of
get_contents/3
and get_address/3
, if Part is unbound,
get_contents/3
will backtrack through all the valid parts of
Datum, binding both Part and Value. A C programmer
might think of the following pairs as corresponding to each other:
Prolog: get_contents(Foo, Bar, Baz) C: Baz = Foo->Bar Prolog: put_contents(Foo, Bar, Baz) C: Foo->Bar = Baz Prolog: get_address(Foo, Bar, Baz) C: Baz = &Foo->Bar.
The hitch is that only atomic and pointer types can be got and put
by get_contents/3
and put_contents/3
. This is because Prolog can
only hold pointers to C structures, not the structures themselves.
This isn't quite as bad as it might seem, though, since usually
structures contain pointers to other structures, anyway. When a
structure directly contains another structure, Prolog can get a
pointer to it with get_address/3
.


 You use Controls to control the behaviour of types of spatials. To control global game behaviour see Application States – you can use both together.
To control the behaviour of types of entities:
spatial.addControl(myControl)
To implement game logic for a type of spatial, you will either extend AbstractControl, or implement the Control interface, as explained in this article.
For example, you could write a CharacterAnimControl that animates a character accordingly while it is being moved by a CharacterControl. Or you can write an AIControl that remote-controls NPC behaviour in fight situatons. Or you could write a DestructionControl that automatically replaces a structure with an appropriate piece of debris after collision with a projectile… The possibilities are endless. Existing examples in the code base include:
The interface can be found under com.jme3.scene.control.Control
. It has the following method signatures:
cloneForSpatial(Spatial)
: Clones the Control and attaches it to a clone of the given Spatial. The AssetManager uses this method if the same spatial is loaded twice. You can specify which fields you want your object to reuse (e.g. collisionshapes) in this case. setEnabled(boolean)
: Enable or disable the control. If disabled, update() does nothing. Goes with accessor isEnabled();
.setSpatial(Spatial s)
, update(float tpf);
, render(RenderManager rm, ViewPort vp)
.If you want to create a Control that also extends an existing class, then create a custom extension of the Control Interface. Usage example: 1. Create a custom control interface
public interface MyControl extends Control { public void setSomething(int x); // add your custom methods }
2. Create custom classes implementing your control interface
public class ControlledThing extends MyThing implements MyControl { protected Spatial spatial; protected boolean enabled = true; public ControlledThing() { } public ControlledThing(int x) { super(x); } @Override public void update(float tpf) { if (enabled && spatial != null) { // ... // Write custom code to control the spatial here! } } @Override public void render(RenderManager rm, ViewPort vp) { // optional, e.g. to display a debug shape } @Override public Control cloneForSpatial(Spatial spatial) { ControlledThing control = new ControlledThing(y); // ... spatial.setControl(control); return control; } @Override public void setEnabled(boolean enabled) { this.enabled = enabled; // ... } @Override public boolean isEnabled() { return enabled; } @Override public void setSomething(int z) { // your custom method ... } @Override public void write(JmeExporter ex) throws IOException { super.write(ex); OutputCapsule oc = ex.getCapsule(this); oc.write(enabled, "enabled", true); oc.write(spatial, "spatial", null); // write custom variables .... } @Override public void read(JmeImporter im) throws IOException { super.read(im); InputCapsule ic = im.getCapsule(this); enabled = ic.readBoolean("enabled", true); spatial = (Spatial) ic.readSavable("spatial", null); // read custom variables .... } }
This class can be found under com.jme3.scene.control.AbstractControl
.
enabled
, and a Spatial spatial
.
Usage: Your custom subclass must implement the three methods controlUpdate()
, controlRender()
, and cloneForSpatial()
as shown here:
public class MyControl extends AbstractControl implements Savable, Cloneable { private Thing thing; // some custom class of yours public MyControl(){} // empty serialization constructor public MyControl(thing) { // some custom constructor super(spatial); this.thing = thing; } @Override protected void controlUpdate(float tpf){ if(spatial != null && thing != null) { // Implement your custom control here ... } } @Override protected void controlRender(RenderManager rm, ViewPort vp){ // ... optional } @Override public Control cloneForSpatial(Spatial spatial){ final MyControl control = new MyControl(...); spatial.setControl(control); return control; } @Override public void read(JmeImporter im) throws IOException { super.read(im); // im.getCapsule(this).read(...); } @Override public void write(JmeExporter ex) throws IOException { super.write(ex); // ex.getCapsule(this).write(...); } }
Tip: Use the getControl() accessor to get Control objects from Spatials. No need to pass around lots of object references. Here an example from the code:
public class CharacterAnimControl implements Control { ... public void setSpatial(Spatial spatial) { ... animControl = spatial.getControl(AnimControl.class); characterControl = spatial.getControl(CharacterControl.class); ... } }
Tip: You can create custom Control interfaces so a set of different Controls provide the same methods and can be accessed with the interface class type.
public interface ManualControl extends Control { public void steerX(float value); public void steerY(float value); public void moveX(float value); public void moveY(float value); public void moveZ(float value); ... }
Then you create custom sub-Controls and implement the methods accordingly to the context:
public class ManualVehicleControl extends ManualControl {...}
and
public class ManualCharacterControl extends ManualControl {...}
Then add the appropriate controls to spatials:
characterSpatial.addControl(new ManualCharacterControl()); ... vehicleSpatial.addControl(new ManualVehicleControl()); ...
Tip: Use the getControl() method on a Spatial to get a specific Control object, and activate its behaviour!
ManualControl c = mySpatial.getControl(ManualControl.class); c.steerX(steerX);


CAAP trains new traffic controllers
by Joel E. ZurbanoThe Civil Aviation Authority of the Philippines announced on Friday it has started accepting applicants for the next batch of trainees to become air traffic controllers.
The agency will be launching its Comprehensive Air Traffic Service Course Batch 15 (CATS 15) this year to recruit young and competent individuals aspiring to be part of the country’s elite line of Air Traffic Management Officers.
“In support of the International Civil Aviation Organization's (ICAO) New Generation of Aviation Professionals (NGAP) initiative, CAAP has been working towards ensuring that there are enough qualified and competent professionals that will maintain the future of the country's air transportation system,” said CAAP chief information officer and spokesperson Eric Apolonio.
Accepted applicants, who must also pass a panel interview and physical examinations, will undergo training at CAAP's Civil Aviation Training Center in Pasay City. Joel E. Zurbano
“Once licensed, successful trainees will become Air Traffic Controller (ATC) assistants and then ATMOs, once rated,” said Apolonio. Joel E. Zurbano


Status Definitions
Verified Profile
ID has been presented and/or profile is linked with BC Services Card Online Authentication. Evacuee is eligible for e-Transfer.
Unverified Profile
ID has NOT been provided and/or profile is NOT linked with BC Services Card Online Authentication. Evacuee is NOT eligible for e-Transfer.


We extend content!
- integrate extensible supply-chains
- transform global relationships
- deploy customized infrastructures
- revolutionize leading-edge deliverables
- synergize interactive initiatives
- matrix frictionless paradigms
- maximize clicks-and-mortar relationships
- innovate user-centric portals
- grow distributed portals
- synthesize front-end technologies
- morph holistic paradigms
- deploy distributed e-business


Eric Wanyama Portfolio
About Me:
Education
- College: Electrical Engineering - UoN
- High School: Bush High School
- Primary: Lugulu Boarding
Job Experience
- Safaricom 2018 Jul - present : Enterprise Insfrastructure Access
- Safaricom 2012 - 2018 Jun : Enterprise Platinum
- Safaricom 2010 - 2012 : TAC Engineer Enterprise Business
- One Communications - : Noc Engineer