mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	time.c split time_utc_or_local
* time.c (time_utc_or_local): split into time_s_mkutc and time_s_mktime without utc flag. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
		
							parent
							
								
									f7b0a791ca
								
							
						
					
					
						commit
						351b8a322e
					
				
					 1 changed files with 10 additions and 18 deletions
				
			
		
							
								
								
									
										28
									
								
								time.c
									
										
									
									
									
								
							
							
						
						
									
										28
									
								
								time.c
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -2437,7 +2437,8 @@ time_s_now(VALUE klass)
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
static int
 | 
			
		||||
get_scale(VALUE unit) {
 | 
			
		||||
get_scale(VALUE unit)
 | 
			
		||||
{
 | 
			
		||||
    if (unit == ID2SYM(id_nanosecond) || unit == ID2SYM(id_nsec)) {
 | 
			
		||||
        return 1000000000;
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			@ -3075,21 +3076,6 @@ tmcmp(struct tm *a, struct tm *b)
 | 
			
		|||
        return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static VALUE
 | 
			
		||||
time_utc_or_local(int argc, VALUE *argv, int utc_p, VALUE klass)
 | 
			
		||||
{
 | 
			
		||||
    struct vtm vtm;
 | 
			
		||||
    VALUE time;
 | 
			
		||||
 | 
			
		||||
    time_arg(argc, argv, &vtm);
 | 
			
		||||
    if (utc_p)
 | 
			
		||||
        time = time_new_timew(klass, timegmw(&vtm));
 | 
			
		||||
    else
 | 
			
		||||
        time = time_new_timew(klass, timelocalw(&vtm));
 | 
			
		||||
    if (utc_p) return time_gmtime(time);
 | 
			
		||||
    return time_localtime(time);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 *  call-seq:
 | 
			
		||||
 *    Time.utc(year) -> time
 | 
			
		||||
| 
						 | 
				
			
			@ -3125,7 +3111,10 @@ time_utc_or_local(int argc, VALUE *argv, int utc_p, VALUE klass)
 | 
			
		|||
static VALUE
 | 
			
		||||
time_s_mkutc(int argc, VALUE *argv, VALUE klass)
 | 
			
		||||
{
 | 
			
		||||
    return time_utc_or_local(argc, argv, TRUE, klass);
 | 
			
		||||
    struct vtm vtm;
 | 
			
		||||
 | 
			
		||||
    time_arg(argc, argv, &vtm);
 | 
			
		||||
    return time_gmtime(time_new_timew(klass, timegmw(&vtm)));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
| 
						 | 
				
			
			@ -3156,7 +3145,10 @@ time_s_mkutc(int argc, VALUE *argv, VALUE klass)
 | 
			
		|||
static VALUE
 | 
			
		||||
time_s_mktime(int argc, VALUE *argv, VALUE klass)
 | 
			
		||||
{
 | 
			
		||||
    return time_utc_or_local(argc, argv, FALSE, klass);
 | 
			
		||||
    struct vtm vtm;
 | 
			
		||||
 | 
			
		||||
    time_arg(argc, argv, &vtm);
 | 
			
		||||
    return time_localtime(time_new_timew(klass, timelocalw(&vtm)));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue