免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1912 | 回复: 2
打印 上一主题 下一主题

ctime.pl用来做什么的? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-09-18 15:36 |只看该作者 |倒序浏览
我发现在程序有require "ctime.pl";
但是在这个目录下没有这个文件,从网上down了一个,好象不对?

  1. ;# ctime.pl is a simple Perl emulation for the well known ctime(3C) function.
  2. #
  3. # This library is no longer being maintained, and is included for backward
  4. # compatibility with Perl 4 programs which may require it.
  5. #
  6. # In particular, this should not be used as an example of modern Perl
  7. # programming techniques.
  8. #
  9. # Suggested alternative: the POSIX ctime function
  10. ;#
  11. ;# Waldemar Kebsch, Federal Republic of Germany, November 1988
  12. ;# kebsch.pad@nixpbe.UUCP
  13. ;# Modified March 1990, Feb 1991 to properly handle timezones
  14. ;#  $RCSfile: ctime.pl,v $$Revision: 4.1 $$Date: 92/08/07 18:23:47 $
  15. ;#   Marion Hakanson (hakanson@cse.ogi.edu)
  16. ;#   Oregon Graduate Institute of Science and Technology
  17. ;#
  18. ;# usage:
  19. ;#
  20. ;#     #include <ctime.pl>          # see the -P and -I option in perl.man
  21. ;#     $Date = &ctime(time);

  22. CONFIG: {
  23.     package ctime;

  24.     @DoW = ('Sun','Mon','Tue','Wed','Thu','Fri','Sat');
  25.     @MoY = ('Jan','Feb','Mar','Apr','May','Jun',
  26.             'Jul','Aug','Sep','Oct','Nov','Dec');
  27. }

  28. sub ctime {
  29.     package ctime;

  30.     local($time) = @_;
  31.     local($[) = 0;
  32.     local($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst);

  33.     # Determine what time zone is in effect.
  34.     # Use GMT if TZ is defined as null, local time if TZ undefined.
  35.     # There's no portable way to find the system default timezone.

  36.     $TZ = defined($ENV{'TZ'}) ? ( $ENV{'TZ'} ? $ENV{'TZ'} : 'GMT' ) : '';
  37.     ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =
  38.         ($TZ eq 'GMT') ? gmtime($time) : localtime($time);

  39.     # Hack to deal with 'PST8PDT' format of TZ
  40.     # Note that this can't deal with all the esoteric forms, but it
  41.     # does recognize the most common: [:]STDoff[DST[off][,rule]]

  42.     if($TZ=~/^([^:\d+\-,]{3,})([+-]?\d{1,2}(:\d{1,2}){0,2})([^\d+\-,]{3,})?/){
  43.         $TZ = $isdst ? $4 : $1;
  44.     }
  45.     $TZ .= ' ' unless $TZ eq '';

  46.     $year += 1900;
  47.     sprintf("%s %s %2d %2d:%02d:%02d %s%4d\n",
  48.       $DoW[$wday], $MoY[$mon], $mday, $hour, $min, $sec, $TZ, $year);
  49. }
  50. 1;

复制代码

论坛徽章:
0
2 [报告]
发表于 2006-09-18 15:38 |只看该作者

回复 1楼 zw2002 的帖子

系统是redhat

论坛徽章:
0
3 [报告]
发表于 2006-09-18 16:02 |只看该作者

回复 2楼 zw2002 的帖子

在系统的目录下找到这个文件了,是一样的。
/usr/lib/perl5/5.8.0/ctime.pl
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP