게임에 디지털 시계를 만들고 있어서 현재 시간(시와 분)을 HH:MM:SS처럼 표시하고 싶어요. 필요한 시간 값은 어디서 얻을 수 있나요?
I'm building a digital clock for my game, so I need the present time (hours and minutes) displayed like this: HH:MM:SS Where do I obtain the time values to do that?
게임에 디지털 시계를 만들고 있어서 현재 시간(시와 분)을 HH:MM:SS처럼 표시하고 싶어요. 필요한 시간 값은 어디서 얻을 수 있나요?
I'm building a digital clock for my game, so I need the present time (hours and minutes) displayed like this: HH:MM:SS Where do I obtain the time values to do that?
Time (https://docs.godotengine.org/en/stable/classes/class_time.html) 싱글턴에는 시스템 시계의 시간 정보를 딕셔너리로 주는 get_datetime_dict_from_system (https://docs.godotengine.org/en/stable/classes/class_time.html#class-time-method-get-datetime-dict-from-system)가 있습니다.
# Read a dictionary of clock fields
var clock_fields = Time.get_time_dict_from_system()
print(clock_fields) # {day:X, dst:False, hour:xx, minute:xx, month:xx, second:xx, weekday:x, year:xxxx}
원하시는 HH:MM 형식에는 시, 분, 초 필드만 주는 더 간단한 get_time_dict_from_system (https://get_time_dict_from_system)를 쓰면 됩니다
var clock_fields = Time.get_time_dict_from_system()
# Format each field with 2 zero-padded digits, e.g. 02:31:24
print("%02d:%02d:%02d" % [clock_fields.hour, clock_fields.minute, clock_fields.second])
이전 Godot 버전(-3.4)에서는 OS.get_time() (https://docs.godotengine.org/en/stable/classes/class_os.html#class-os-method-get-time)도 쓸 수 있지만 3.5+에서는 사용 중단 예정이고 4.x에서는 없어졌습니다:
The Time (https://docs.godotengine.org/en/stable/classes/class_time.html) singleton provides get_datetime_dict_from_system (https://docs.godotengine.org/en/stable/classes/class_time.html#class-time-method-get-datetime-dict-from-system), which gives you a dictionary containing time information obtained from the system clock.
# Read a dictionary of clock fields
var clock_fields = Time.get_time_dict_from_system()
print(clock_fields) # {day:X, dst:False, hour:xx, minute:xx, month:xx, second:xx, weekday:x, year:xxxx}
For your HH:MM formatting, the simpler get_time_dict_from_system (https://get_time_dict_from_system) gives just the hour, minute and second fields
var clock_fields = Time.get_time_dict_from_system()
# Format each field with 2 zero-padded digits, e.g. 02:31:24
print("%02d:%02d:%02d" % [clock_fields.hour, clock_fields.minute, clock_fields.second])
On earlier Godot releases (-3.4), you can also call OS.get_time() (https://docs.godotengine.org/en/stable/classes/class_os.html#class-os-method-get-time), though it is deprecated in 3.5+ and gone in 4.x:
Godot 4.x에서는 Time.get_time_string_from_system() (https://docs.godotengine.org/en/stable/classes/class_time.html#class-time-method-get-time-string-from-system)가 시스템 시계의 시간을 이미 HH:MM:SS 형식인 문자열로 반환합니다.
With Godot 4.x, Time.get_time_string_from_system() (https://docs.godotengine.org/en/stable/classes/class_time.html#class-time-method-get-time-string-from-system) gives the system clock time as a string already using the HH:MM:SS format.
제가 시도한 명령: 그런데 이 명령은 없는 모양이에요. gdb에서 이런 걸 할 수 있나요?
텍스트에 one 또는 two 중 하나가 들어 있는지 확인하고 싶어요: Playwright에서 이렇게 동작하게 할 수 있나요? 같은 걸 문장 안에도 넣을 수 있을까요, 예를 들면
제 코드에 이런 함수가 있어요: TsLint에서 다음 오류를 보고해요: 이 메시지가 무슨 뜻인지 설명해 주실 분 있나요?