Time-Warp-0.55/0000755000175000017500000000000014311647415012612 5ustar manwarmanwarTime-Warp-0.55/.travis.yml0000644000175000017500000000017314311646215014721 0ustar manwarmanwarbranches: except: - gh-pages language: perl perl: - "5.20" - "5.18" - "5.16" - "5.14" - "5.12" - "5.10" Time-Warp-0.55/Changes0000644000175000017500000000212014311647346014103 0ustar manwarmanwarRevision history for Time::Warp 0.55 2022.09.18 MANWAR Test warnings and edge cases #5 by @choroba Fix code and tests to Time::HiRes implicitly loaded by Test::More #8 by @ppisar 0.54 2018.10.08 MANWAR - Merged PR #4 (Pod Spelling), thanks @gregoa. 0.53 2018.08.22 - New maintainer (MANWAR) - Updated GitHub repo details. - Tidied up Changes. 0.52 2015.04.16 - The type of the Time::NVtime pointer is NV ()() not double ()(), as can be seen from looking at the Time::HiRes source. On Linux x86_64 on a uselongdouble build when you replace the Time::NVtime entry with a double (*)() pointer calls to that function end up leaving an entry on the FPU stack, eventually causing the failure seen at https://rt.perl.org/Ticket/Display.html?id=123879 This minimal commit fixes that issue and allows DBIX::Class::TimeStamp to pass its tests. (Tony Cook) 0.51 2014.10.17 - New maintainer (SZABGAB) - Use Test::More instead of Test - Include META.yml RT #77752 - POD encoding is now utf8 RT #93259 Time-Warp-0.55/Makefile.PL0000644000175000017500000000165414311647174014574 0ustar manwarmanwaruse ExtUtils::MakeMaker; require 5.006; my %conf = ( NAME => 'Time::Warp', AUTHOR => 'Joshua Nathaniel Pritikin ', VERSION_FROM => 'Warp.pm', ABSTRACT_FROM => 'Warp.pm', LICENSE => 'perl', OBJECT => 'Warp.o', OPTIMIZE => '-g', PREREQ_PM => { 'Test::More' => '1.00', }, ); if (eval { ExtUtils::MakeMaker->VERSION(6.46) }) { $conf{META_MERGE} = { 'meta-spec' => { version => 2 }, resources => { repository => { type => 'git', url => 'http://github.com/manwar/Time-Warp.git', web => 'http://github.com/manwar/Time-Warp', license => 'http://dev.perl.org/licenses/', }, bugtracker => { web => 'http://github.com/manwar/Time-Warp', }, }, }; } WriteMakefile(%conf); Time-Warp-0.55/MANIFEST0000644000175000017500000000040614311647416013744 0ustar manwarmanwar.travis.yml Changes Makefile.PL MANIFEST This list of files README t/when.t Warp.pm Warp.xs META.yml Module YAML meta-data (added by MakeMaker) META.json Module JSON meta-data (added by MakeMaker) Time-Warp-0.55/META.json0000644000175000017500000000240214311647415014231 0ustar manwarmanwar{ "abstract" : "control over the flow of time", "author" : [ "Joshua Nathaniel Pritikin " ], "dynamic_config" : 1, "generated_by" : "ExtUtils::MakeMaker version 7.34, CPAN::Meta::Converter version 2.150010", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "Time-Warp", "no_index" : { "directory" : [ "t", "inc" ] }, "prereqs" : { "build" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "runtime" : { "requires" : { "Test::More" : "1.00" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "http://github.com/manwar/Time-Warp" }, "repository" : { "type" : "git", "url" : "http://github.com/manwar/Time-Warp.git", "web" : "http://github.com/manwar/Time-Warp", "x_license" : "http://dev.perl.org/licenses/" } }, "version" : "0.55", "x_serialization_backend" : "JSON::PP version 4.02" } Time-Warp-0.55/META.yml0000644000175000017500000000125514311647413014064 0ustar manwarmanwar--- abstract: 'control over the flow of time' author: - 'Joshua Nathaniel Pritikin ' build_requires: ExtUtils::MakeMaker: '0' configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 1 generated_by: 'ExtUtils::MakeMaker version 7.34, CPAN::Meta::Converter version 2.150010' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: Time-Warp no_index: directory: - t - inc requires: Test::More: '1.00' resources: bugtracker: http://github.com/manwar/Time-Warp repository: http://github.com/manwar/Time-Warp.git version: '0.55' x_serialization_backend: 'CPAN::Meta::YAML version 0.018' Time-Warp-0.55/README0000644000175000017500000000035114311647025013466 0ustar manwarmanwarTime::Warp - offers developers control over the measurement of time SYNOPSIS use Time::Warp qw(scale to time); to(CORE::time + 5); # 5 seconds ahead scale(2); # double speed of time AVAILABLE FROM CPAN! Time-Warp-0.55/t/0000755000175000017500000000000014311647412013052 5ustar manwarmanwarTime-Warp-0.55/t/when.t0000644000175000017500000000205514311646643014207 0ustar manwarmanwaruse strict; use warnings; use Test::More tests => 8; # Use an overloaded time() (e.g. by Time::HiRes), or CORE::time as a reference # clock. my $ref_time = (exists $main::{'time'}) ? $main::{'time'} : $CORE::{'time'}; { my $time_hires_warning_emitted; local $SIG{__WARN__} = sub { if ($_[0] =~ /Time::HiRes/) { $time_hires_warning_emitted = 1; } else { warn $_[0]; } }; require Time::Warp; ok ($time_hires_warning_emitted xor exists $INC{'Time/HiRes.pm'}); } Time::Warp->import(qw(time to scale)); ok 1; is scale(), 1; # These tests may occationally fail due to small timing differences. sub approx { my ($got, $expected) = @_; my $epsilon = 0.3 * scale(); ok($got - $expected < $epsilon, "$got is approximately equivalent to $expected with a tolerance $epsilon"); } scale(2); is &scale, 2; my $now = &time; sleep 2; approx(&time - $now, 4); to(&$ref_time); approx(&time - &$ref_time, 0); scale(scale() * 2); approx(&time - &$ref_time, 0); Time::Warp::reset(); to(&time + 5); approx(&time - &$ref_time, 5); Time-Warp-0.55/Warp.pm0000644000175000017500000000412214311647156014062 0ustar manwarmanwaruse strict; package Time::Warp; use vars qw(@ISA @EXPORT_OK $VERSION); require Exporter; require DynaLoader; @ISA = qw(DynaLoader Exporter); @EXPORT_OK = qw(reset to scale time); $VERSION = '0.55'; __PACKAGE__->bootstrap($VERSION); install_time_api(); 1; __END__ =encoding utf8 =head1 NAME Time::Warp - control over the flow of time =head1 SYNOPSIS use Time::Warp qw(scale to time); to(time + 5); # 5 seconds ahead scale(2); # make time flow twice normal =head1 DESCRIPTION Our external experience unfolds in 3 1/2 dimensions (time has a dimensionality of 1/2). The Time::Warp module offers developers control over the measurement of time. =head1 API =over 4 =item * to($desired_time) The theory of relativity asserts that all physical laws are enforced relative to the observer. Since the starting point of time is arbitrary, it is permissible to change it. This has the effect of making it appear as if time is moving forwards or backward instanteously. For example, on some types of operating systems time starts at Wed Dec 31 19:00:00 1969 (this will likely change as we approach 2030 and with the acceptance of 64-bit CPUs). to(time + 60*60); # 1 hour ahead =item * scale($factor) Changes the speed at which time is progressing. scale(scale * 2); # double the speed of time Note that it is not possible to stop time or cause it to reverse since this is forbidden by the second law of thermodynamics. =back =head1 ALSO SEE L and L. =head1 SUPPORT Please direct your insights or complaints to perl-loop@perl.org. =head1 DISCLAIMER THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THIS IS NOT A TIME MACHINE. THIS MODULE CANNOT BE USED TO VIOLATE THE SECOND LAW OF THERMODYNAMICS. =head1 COPYRIGHT Copyright © 1999, 2000 Joshua Nathaniel Pritikin. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut Time-Warp-0.55/Warp.xs0000644000175000017500000000521214311646643014101 0ustar manwarmanwar#ifdef __cplusplus extern "C" { #endif #define MIN_PERL_DEFINE 1 #include "EXTERN.h" #include "perl.h" #include "XSUB.h" #ifdef __cplusplus } #endif /* Is time() portable everywhere? Hope so! XXX */ static NV fallback_NVtime() { return time(0); } static void fallback_U2time(U32 *ret) { ret[0]=time(0); ret[1]=0; } /*-----------------*/ static int Installed=0; static NV (*realNVtime)(); static void (*realU2time)(U32 *); static double Lost; /** time relative to now */ static double Scale; /** speed of time (.5 == half speed) */ static void reset_warp() { Lost=0; Scale=1; } /*-----------------*/ static NV warped_NVtime() { return (*realNVtime)() * Scale + Lost; } static void warped_U2time(U32 *ret) { /* performance doesn't matter enough for a native non-float implementation */ double now = warped_NVtime(); U32 unow = now; ret[0] = unow; ret[1] = (now - unow) * 1000000; } MODULE = Time::Warp PACKAGE = Time::Warp PROTOTYPES: ENABLE void install_time_api() CODE: { SV **svp; if (Installed) { warn("Time::Warp::install_time_api() called more than once"); return; } Installed=1; svp = hv_fetch(PL_modglobal, "Time::NVtime", 12, 0); if (!svp) { warn("Time::Warp: Time::HiRes is not loaded --\n\tat best 1s time accuracy is available"); hv_store(PL_modglobal, "Time::NVtime", 12, newSViv((IV) fallback_NVtime), 0); hv_store(PL_modglobal, "Time::U2time", 12, newSViv((IV) fallback_U2time), 0); } svp = hv_fetch(PL_modglobal, "Time::NVtime", 12, 0); if (!SvIOK(*svp)) croak("Time::NVtime isn't a function pointer"); realNVtime = (NV(*)()) SvIV(*svp); svp = hv_fetch(PL_modglobal, "Time::U2time", 12, 0); if (!SvIOK(*svp)) croak("Time::U2time isn't a function pointer"); realU2time = (void(*)(U32*)) SvIV(*svp); hv_store(PL_modglobal, "Time::NVtime", 12, newSViv((IV) warped_NVtime), 0); hv_store(PL_modglobal, "Time::U2time", 12, newSViv((IV) warped_U2time), 0); reset_warp(); } void reset() CODE: reset_warp(); void to(when) double when CODE: { Lost = when - (*realNVtime)() * Scale; } void scale(...) PREINIT: double new_Scale; PPCODE: { if (items == 0) { XPUSHs(sv_2mortal(newSVnv(Scale))); } else { new_Scale = SvNV(ST(0)); if (new_Scale < 0) { warn("Sorry, Time::Warp cannot go backwards"); new_Scale = 1; } else if (new_Scale < .001) { warn("Sorry, Time::Warp cannot stop time"); new_Scale = .001; } Lost += (*realNVtime)() * (Scale - new_Scale); Scale = new_Scale; } } void time() PPCODE: { XPUSHs(sv_2mortal(newSVnv(warped_NVtime()))); }